Skip to content

Finished Projects#2

Closed
jakeacooley wants to merge 8 commits into
bloominstituteoftechnology:masterfrom
jakeacooley:master
Closed

Finished Projects#2
jakeacooley wants to merge 8 commits into
bloominstituteoftechnology:masterfrom
jakeacooley:master

Conversation

@jakeacooley

Copy link
Copy Markdown

No description provided.

@taithethai taithethai left a comment

Copy link
Copy Markdown
Contributor

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;

Comment thread src/project-1.js
// return num after multiplying it by ten
// code here
num *= 10;
return num;

@taithethai taithethai Aug 19, 2017

Copy link
Copy Markdown
Contributor

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.

Comment thread src/project-1.js
// return true if the two strings have the same length
// otherwise return false
// code here
if (str1.length === str2.length) {

Copy link
Copy Markdown
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;

Comment thread src/project-1.js
// otherwise return false
// code here

if (x === y) {

Copy link
Copy Markdown
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.

Comment thread src/project-1.js
// otherwise return false
// code here

if (num < 90) {

Copy link
Copy Markdown
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.

Comment thread src/project-1.js
// return true if x and y are the same
// otherwise return false
// code here

Copy link
Copy Markdown
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.

Comment thread src/project-2.js
@@ -3,6 +3,12 @@
const getBiggest = (x, y) => {

Copy link
Copy Markdown
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.

Comment thread src/project-2.js
return x;
};

const greeting = (language) => {

Copy link
Copy Markdown
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

Comment thread src/project-2.js
return false;
};

const isInteger = (num) => {

Copy link
Copy Markdown
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.

Comment thread src/project-2.js
return sum;
};

const averageTestScore = (testScores) => {

Copy link
Copy Markdown
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.

Comment thread src/project-3.js
const catObject = {
name,
age,
meow: () => {

Copy link
Copy Markdown
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