-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Simon Ertel [WDFT June 2020 Berlin] #1677
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nice functions here! Happy to discuss any concepts you might not have fully grasped if you'd like though.
if (a === b) { | ||
return a || b; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet. Could refactor it slightly so it's a bit shorter:
function maxOfTwoNumbers(n1, n2) {
if (n1 > n2) {
return n1;
}
return n2;
}
src/functions-and-arrays.js
Outdated
// return 0; | ||
//} | ||
let sum = 0; | ||
for (i = 0; i < arr.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to declare i
so the for loop can run.
return sum; | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function completes but it resolves to 18miami1truebarca200lisboa810
as it's the same as the one before. We can go through this if you'd like?
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works when the i
is defined. Just make sure to add the let
on line 69
return (wordAvg / wordCount); | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the best way to attempt this one would be something like...
- declare a variable for the total
- create a for loop
- Add the length of each word within the array to the total (
total += wordsArr[i].length;
) - return the average (
total / wordsarr.length
)
return unique; | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nicely done!
return false; | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also looks good! Nice one
src/functions-and-arrays.js
Outdated
|
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't make this one work as expected. We can go through it if you like? I would have probably:
- created a variable to check for true or false
- run a for loop to compare the words in the array to the second argument
- stop the loop and return the check variable depending on the answer
function doesWordExist(wordsFind, word) {
let check = true;
for (let i = 0; i < wordsFind.length; i++) {
if (wordsFind[i] === word) {
check = true;
break;
could do this with the .include method
}
check = false;
}
return check;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Tim, thanks a lot for your feedback. Was really helpfull.
Yeah didn't declare the i's, thx for the hint. I wondered why it didn't work.
A lot became clearer this morning during the recap of the lab with Jan. I understood the concept of the for of loop and used it in the iterations.
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. |
This pull request is closed. Thank you. |
Simon Ertel [WDFT June 2020 Berlin]