Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BER_FT_03_23_23_HeimLi#3683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
HeimLi wants to merge1 commit intoironhack-labs:masterfromHeimLi:master
Closed

Conversation

HeimLi
Copy link

No description provided.

if (num1 > num2) { return num1 }
else { return num2 }
}
result = maxOfTwoNumbers(3, 5);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You don't need to call your function here to make it work. If you use it, to test your code, that's fine! 😉 But you should better remove these function calls before you submit the lab.

//console.log(typeof (wordLength));

for (let i = 0; i < words.length; i++) {
if (wordLength.length < words[i].length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Better store the longest word in a string, not an array and just compare the length by using longestWord.length

return averageNumbersSum/2
}

let result4 = averageNumbers(numbersAvg);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You should divide the total sum by the amount of numbers in the array to get the average


for (let i = 0; i < wordsUnique.length; i++) {

if (newArray.includes(wordsUnique[i])) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You could also check if the array doesn't include the word by using!newArray.includes(wordsUnique[i]), then you don't need an else


for (let i = 0; i < wordsFind.length; i++) {
if (wordsFind.includes(givenWord)) {
console.log("true"); break

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good solution, you just need to replace the console.log with a return-statement

howManyTimes,
greatestProduct
};
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good solutions! ✨ Keep on the good work!

@HeimLi
Copy link
Author

HeimLi commentedMar 28, 2023 via email

Danke!:)Marco Lölkes ***@***.***> schrieb am Di. 28. März 2023 um17:52:
***@***.**** commented on this pull request. ------------------------------ In src/functions-and-arrays.js <#3683 (comment)> : > @@ -1,41 +1,96 @@ // Iteration#1: Find the maximum -function maxOfTwoNumbers() {} +function maxOfTwoNumbers(num1, num2) { + if (num1 > num2) { return num1 } + else { return num2 } +} +result = maxOfTwoNumbers(3, 5); You don't need to call your function here to make it work. If you use it, to test your code, that's fine! 😉 But you should better remove these function calls before you submit the lab. ------------------------------ In src/functions-and-arrays.js <#3683 (comment)> : > // Iteration#2: Find longest word + +function findLongestWord(words) { + + let wordLength = []; + wordLength.push(words[0]); + //console.log(wordLength); + //console.log(typeof (wordLength)); + + for (let i = 0; i < words.length; i++) { + if (wordLength.length < words[i].length) { Better store the longest word in a string, not an array and just compare the length by using longestWord.length ------------------------------ In src/functions-and-arrays.js <#3683 (comment)> : > // Iteration#4: Calculate the average // Level 1: Array of numbers const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9]; -function averageNumbers() {} +function averageNumbers(numbersAvg) { + let averageNumbersSum = 0; + + for (let i = 0; i < numbersAvg.length; i++) { + averageNumbersSum = averageNumbersSum + numbersAvg[i] + } + return averageNumbersSum/2 +} + +let result4 = averageNumbers(numbersAvg); You should divide the total sum by the amount of numbers in the array to get the average ------------------------------ In src/functions-and-arrays.js <#3683 (comment)> : > @@ -52,15 +107,37 @@ const wordsUnique = [ 'bring' ]; -function uniquifyArray() {} +function uniquifyArray(wordsUnique) { + + let newArray = []; + + for (let i = 0; i < wordsUnique.length; i++) { + + if (newArray.includes(wordsUnique[i])) { You could also check if the array doesn't include the word by using !newArray.includes(wordsUnique[i]), then you don't need an else ------------------------------ In src/functions-and-arrays.js <#3683 (comment)> : > + for (let i = 0; i < wordsFind.length; i++) { + if (wordsFind.includes(givenWord)) { + console.log("true"); break Good solution, you just need to replace the console.log with a return-statement ------------------------------ In src/functions-and-arrays.js <#3683 (comment)> : > - }; -} + module.exports = { + maxOfTwoNumbers, + findLongestWord, + sumNumbers, + sum, + averageNumbers, + averageWordLength, + avg, + uniquifyArray, + doesWordExist, + howManyTimes, + greatestProduct + }; + } Good solutions! ✨ Keep on the good work! — Reply to this email directly, view it on GitHub <#3683 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/A6NA4S5LEMY3EDYZ6VUNCZ3W6MCM5ANCNFSM6AAAAAAWFPJWO4> . You are receiving this because you authored the thread.Message ID: <ironhack-labs/lab-javascript-functions-and-arrays/pull/3683/review/1361318361 @github.com>

@stale
Copy link

stalebot commentedMay 22, 2023

This pull request has been automatically marked as stale because it didn't have any recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelMay 22, 2023
@stale
Copy link

stalebot commentedMay 31, 2023

This pull request is closed. Thank you.

@stalestalebot closed thisMay 31, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@mloelkesmloelkesmloelkes left review comments

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@HeimLi@mloelkes

[8]ページ先頭

©2009-2025 Movatter.jp