Conversation
|
|
||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| return num >= lower && num <= upper ? true : false; |
There was a problem hiding this comment.
This ternary operator isn't required. num >= lower && num <= upper will return either true or false (depending on the values of num, lower, and upper). Therefore you can just return that boolean value:
return num >= lower && num <= upper|
|
||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| return val1 == 'Hello' || val1 == 'Goodbye' ? true : false; |
There was a problem hiding this comment.
Same as above - return val1 == 'Hello' || var1 == 'Goodbye' will create a boolean value. Therefore we can just return that value.
return val1 == 'Hello' || var1 == 'Goodbye'|
|
||
| // TODO: write code in this function body to pass the tests | ||
| return age === 0 ? 'Baby' : | ||
| age >= 1 && age <= 4 ? 'Toddler' : |
There was a problem hiding this comment.
Nested ternaries are not a good idea to use generally. They're not easy to read, and harder to maintain than if/else statements. It's especially hard if you wanted to add a new case to match; for example if you wanted to add a new age description such as "Young adult"
|
|
||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| return array.length == 0 ? true : false; |
There was a problem hiding this comment.
As I've mentioned above, this can be simplified to
return array.length == 0|
|
||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (num1 > num2) { |
There was a problem hiding this comment.
num1 > num2 creates a boolean value. So like above with the comments about ternary statements; you can just return this value.
return num1 > num2| function isHello(val1) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1 == 'Hello') { |
There was a problem hiding this comment.
Same as above, you don't need the if statement here, you can just return val1 == 'Hello'
| // TODO: Update the code below so that the tests pass | ||
|
|
||
| const numOnePlusNumTwo = 0 // Set this variable to numOne plus numTwo | ||
| const numOnePlusNumTwo = 12 // Set this variable to numOne plus numTwo |
There was a problem hiding this comment.
This should be achieving using numOne + numTwo. However based off the rest of your submission I feel you understand how you can add two variables together :)
No description provided.