-
Notifications
You must be signed in to change notification settings - Fork 137
Finished Projects #2
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
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.
For a lot of your code, you should remove the extra lines, and you could put them on one line. You can also return what's inside the if statement if that is the only thing that function is doing:
const verifyPassword = (user, password) => {
// check to see if the provided password matches the password property on the user object
// return true if they match
// otherwise return false
if (user.password === password) return true;
return false;
to
const verifyPassword = (user, password) => user.password === password;
| // return num after multiplying it by ten | ||
| // code here | ||
| num *= 10; | ||
| return 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.
Here, you could write something like
const multiplyByTen = num => num * 10 with an implicit return.
| // return true if the two strings have the same length | ||
| // otherwise return false | ||
| // code here | ||
| if (str1.length === str2.length) { |
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 return what's inside the if statement, in the format
const areSameLength = (str1, str2) => str1.length === str2.length;
| // otherwise return false | ||
| // code here | ||
|
|
||
| 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.
Same as previous, return what's inside the if statement.
| // otherwise return false | ||
| // code here | ||
|
|
||
| if (num < 90) { |
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.
Same as previous, return what's inside the if statement.
| // return true if x and y are the same | ||
| // otherwise return false | ||
| // code here | ||
|
|
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.
| @@ -3,6 +3,12 @@ | ||
| const getBiggest = (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.
Ternary operator could be useful here. Also, on line 6, you could be checking for x >= y to remove a few lines of code. If that if statement doesn't pass, you know to return y.
| return x; | ||
| }; | ||
|
|
||
| const greeting = (language) => { |
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.
If your base case matches one of your cases, you can just drop the else if (language === 'English').
I'd also suggest using switch cases to reduce code size.
Lookup table would be fastest.
https://jsperf.com/if-switch-lookup-table/10
| return false; | ||
| }; | ||
|
|
||
| const isInteger = (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.
Here I'd suggest besides putting all the code on one line, I'd also suggest returning num === Math.floor(num) over modulo.
| return sum; | ||
| }; | ||
|
|
||
| const averageTestScore = (testScores) => { |
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 use reduce here.
| const catObject = { | ||
| 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!'
No description provided.