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

Appearance settings

Conversation

@jakeacooley
Copy link

No description provided.

Copy link
Contributor

@taithethai taithethai left a 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;
Copy link
Contributor

@taithethai taithethai Aug 19, 2017

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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) => {
Copy link
Contributor

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: () => {
Copy link
Contributor

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!'

@taithethai taithethai closed this Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.