-
Notifications
You must be signed in to change notification settings - Fork 137
Finished with Drew Mueller #24
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
| }; | ||
|
|
||
| const lessThanNinety = (num) => { | ||
|
|
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.
Be careful about adding extra lines. Spacing and layout is pretty important. Your senior devs at a future job will be super strict about this stuff
| // Do not change any of the function names | ||
|
|
||
| const getBiggest = (x, y) => { | ||
| if (x > y) { |
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 often like to write simple if statements like this: if (x > y) return x;
| Spanish: 'Hola!', | ||
| Chinese: 'Ni Hao!', | ||
| }; | ||
| return translations[language] || 'Hello!'; |
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 is a creative approach. You could also do something along the lines of setting a default parameter: (language = 'English') => {.
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.
It's fine how you had it though
| }; | ||
|
|
||
| const isInteger = (num) => { | ||
| const isInteger = num => Math.floor(num) === num; |
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.
Creative use of floor. You can also use parseInt to do a similar thing. It drops everything after the decimal
| }; | ||
|
|
||
| const returnLast = (arr) => { | ||
| const returnLast = arr => arr.pop(); |
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.
arr.pop() removes the last item from the array. You should do: arr[arr.length - 1]; . This just reads the last item in the array.
| }; | ||
|
|
||
| const wordsToSentence = (words) => { | ||
| return `${words.join(' ')}`; |
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 could just do return words.join(' ');. It automatically converts it into a string
|
|
||
| const contains = (arr, item) => { | ||
| return arr.includes(item); | ||
|
|
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.
remove the extra space and you could put this on one line
|
|
||
| const addNumbers = (numbers) => { | ||
| // numbers is an array of integers. | ||
| let out = 0; |
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.
Good work. You could also use Array.reduce
|
|
||
| const largestNumber = (numbers) => { | ||
| let biggestNumber = numbers[0]; | ||
| for (let i = 0; i < numbers.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.
Good. You could start i = 1 instead of 0 because you've assigned the first value to biggestNumber
| const newObject = { | ||
| name, | ||
| age, | ||
| meow: () => { |
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.
Great, you could also write it as meow: () => 'Meow!'
| }; | ||
|
|
||
| const sumUserPostLikes = (user) => { | ||
| let sum = 0; |
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.
reduce would work here as well. In the future you'll want to use map, forEach, and reduce whenever possible. This current solution is fine but in the future you'll want to solve these differently :)
| const removeDuplicates = (collection, cb) => { | ||
| // Write a function called removeDuplicates that removes all duplicate values from the given array. | ||
| // Pass the array to the callback function. Do not mutate the original array. | ||
| cb(Array.from(new Set(collection))); |
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.
Good use of Set and Array.from
No description provided.