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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions 31 .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
"import"
],
"consistent-return": 0,
"rules": {
"no-param-reassign": 0,
"max-len": 0,
"no-plusplus": 0,
"linebreak-style": 0,
"consistent-return": 0,
"no-useless-return": 0,
"no-return-assign": 0,
"comma-dangle": 0,
"arrow-body-style": 0,
"max-len": 0,
"no-unused-vars": 0,
"no-useless-constructor": 0,
"import/no-unresolved": 0
}
"rules": {
"no-param-reassign": 0,
"max-len": 0,
"no-plusplus": 0,
"linebreak-style": 0,
"consistent-return": 0,
"no-useless-return": 0,
"no-return-assign": 0,
"comma-dangle": 0,
"arrow-body-style": 0,
"max-len": 0,
"no-unused-vars": 0,
"no-useless-constructor": 0,
"no-extend-native": 0,
"import/no-unresolved": 0
}
}
88 changes: 83 additions & 5 deletions 88 src/project-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,137 +3,215 @@
const multiplyByTen = (num) => {
// 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.

};

const subtractFive = (num) => {
const subtractFive = num => num - 5;
// return num after subtracting five
// code here
};

const areSameLength = (str1, str2) => {
// 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;

return true;
}
return false;
};

const areEqual = (x, y) => {
// 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.

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.

return true;
}
return false;
};

const lessThanNinety = (num) => {
// return true if num is less than ninety
// 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;
}
return false;
};

const greaterThanFifty = (num) => {
// return true if num is greater than fifty
// otherwise return false
// code here

if (num > 50) {
return true;
}
return false;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return what's inside the if statement, remove the extra empty lines.


const add = (x, y) => {
// add x and y together and return the value
// code here

const sum = x + y;

return sum;
};

const subtract = (x, y) => {
// subtract y from x and return the value
// code here

const remainder = x - y;

return remainder;
};

const divide = (x, y) => {
// divide x by y and return the value
// code here

const divided = x / y;

return divided;
};

const multiply = (x, y) => {
// multiply x by y and return the value
// code here

const product = x * y;

return product;
};

const getRemainder = (x, y) => {
// return the remainder from dividing x by y
// code here

const modulo = x % y;

return modulo;
};

const isEven = (num) => {
// return true if num is even
// otherwise return false
// code here

if ((num % 2) === 0) {
return true;
}
return false;
};

const isOdd = (num) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the extra lines, and you could put this on one line.
Also, you could see if num % 2 === 1.

// return true if num is false
// otherwise return false
// code here

if ((num % 2) !== 0) {
return true;
}
return false;
};

const square = (num) => {
// square num and return the new value
// code here

const squared = num * num;

return squared;
};

const cube = (num) => {
// cube num and return the new value
// code here
return num ** 3;
};

const raiseToPower = (num, exponent) => {
// raise num to whatever power is passed in as exponent
// code here

const raisedToPower = num ** exponent;

return raisedToPower;
};

const roundNumber = (num) => {
// round num and return it
// code here

const roundedNumber = Math.round(num);

return roundedNumber;
};

const roundUp = (num) => {
// round num up and return it
// code here

const roundedUp = Math.ceil(num);

return roundedUp;
};

const addExclamationPoint = (str) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of template literal.

// add an exclamation point to the end of str and return the new string
// 'hello world' -> 'hello world!'
// code here

return `${str}!`;
};

const combineNames = (firstName, lastName) => {
// return firstName and lastName combined as one string and separated by a space.
// 'Lambda', 'School' -> 'Lambda School'
// code here

return `${firstName} ${lastName}`;
};

const getGreeting = (name) => {
// Take the name string and concatenate other strings onto it so it takes the following form:
// 'Sam' -> 'Hello Sam!'
// code here

return `Hello ${name}!`;
};

// If you can't remember these area formulas then head over to Google or look at the test code.

const getRectangleArea = (length, width) => {
// return the area of the rectangle by using length and width
// code here

return length * width;
};

const getTriangleArea = (base, height) => {
// return the area of the triangle by using base and height
// code here

return (base * height) / 2;
};

const getCircleArea = (radius) => {
// return the rounded area of the circle given the radius
// code here

return (Math.round(Math.PI * (radius ** 2)));
};

const getRectangularPrismVolume = (length, width, height) => {
// return the volume of the 3D rectangular prism given the length, width, and height
// code here

return length * width * height;
};

// Do not modify code below this line.
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.