-
Notifications
You must be signed in to change notification settings - Fork 137
Project completed #5
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
Project completed #5
Conversation
updated the FizzBuzz code
updated problems
Refactored to use ES6 single-line functions where necessary.
All done
re-structured the code based on the solutions lecture
taithethai
left a comment
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.
Overall good clean code. Just a few improvements to be made.
| // 'hello world' -> 'hello world!' | ||
| // code here | ||
| }; | ||
| const combineNames = (firstName, lastName) => firstName + ' '.concat(lastName); |
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 use template literal here.
| // 'Lambda', 'School' -> 'Lambda School' | ||
| // code here | ||
| }; | ||
| const getGreeting = name => 'Hello '.concat(name).concat('!'); |
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 use template literal here.
| return result; | ||
| }; | ||
|
|
||
| const isPrime = (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.
Prematurely returning.
| } return false; | ||
| }; | ||
|
|
||
| const returnFirst = (arr) => { |
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're returning the last item in the array here.
Also, naming a variable l could be confusing for other people to see.
| // return a string that is all of the words concatenated together | ||
| // spaces need to be between each word | ||
| // example: ['Hello', 'world!'] -> 'Hello world!' | ||
| const mySentence = 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.
could return words.join(' ') here.
| return object; | ||
| }; | ||
|
|
||
| const newUser = (name, email, password) => { |
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 solution. You really just need return an object.
| // sum together the likes from all the post objects | ||
| // return the sum | ||
| let total = 0; | ||
| user.posts.forEach((t, 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 could reduce here.
| const forEach = (arr, cb) => { | ||
| // iterate over arr and pass its values to cb one by one | ||
| // hint: you will be invoking cb multiple times (once for each value in the array) | ||
| arr.forEach((t, 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.
For this project, you should re-create forEach.
| const addPrototypeMethod = (Constructor) => { | ||
| // add a method to the constructor's prototype | ||
| // the method should be called 'sayHi' and should return the string 'Hello World!' | ||
| Constructor.prototype.sayHi = () => { |
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 could be on one line.
| }; | ||
| }; | ||
|
|
||
| const nFactorial = (n) => { |
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 isn't recursively solved, but you're pretty close to doing it recursively.
all done 👍