-
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
Changes from all commits
49a7149
e9ccca9
de9abbe
5f79ffd
86fe035
bbc1e92
5041ad0
e5bb832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,137 +3,215 @@ | |
| const multiplyByTen = (num) => { | ||
| // return num after multiplying it by ten | ||
| // code here | ||
| num *= 10; | ||
| return num; | ||
| }; | ||
|
|
||
| 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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| return true; | ||
| } | ||
| return false; | ||
| }; | ||
|
|
||
| const areEqual = (x, y) => { | ||
| // return true if x and y are the same | ||
| // otherwise return false | ||
| // code here | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the extra lines, and you could put this on one line. |
||
| // 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) => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.
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 * 10with an implicit return.