Conversation
| function isInRange(num, lower, upper) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (num >= lower && num <= upper) { |
There was a problem hiding this comment.
This can be simplified. num >= lower && num <= upper creates a boolean value that represents if num is greater than or equal to lower AND is less than or equal to upper. So we can just return that value instead of doing the if statement. Like so:
return num >= lower && num <= upper| function isHelloOrGoodbye(val1) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1 == "Hello" || val1 == "Goodbye") { |
There was a problem hiding this comment.
This can also be simplified:
return val1 == 'Hello' || val1 == 'Goodbye'| // TODO: write code in this function body to pass the tests | ||
| const arrayCheck = []; | ||
|
|
||
| if (array.length == arrayCheck) { |
There was a problem hiding this comment.
I would be careful doing this. It does work, but in a little bit of a hacky way. If you wanted to compare the array to an empty array, you could do this like so:
if (array === arrayCheck)However, by checking the length (which will be 0) against the array, you're actually doing something like this:
if (0 === [])Javascript will let you do this, but a lot of languages won't. So just be careful!
| function isGreaterThan(num1, num2) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (num1 > num2) { |
There was a problem hiding this comment.
This can also be simplified, same as above :)
| function findLowest(nums) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| m = Math.min(...nums); { |
There was a problem hiding this comment.
You could just return Math.min(...nums) here
| function isHello(val1) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1 === "Hello") { |
| if (val1 === "Hello") { | ||
| return true; | ||
| } | ||
| if (val1 !== "Hello") { |
There was a problem hiding this comment.
If you did simplify the above, you wouldn't need this if statement.
| function isNotHello(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 can simplify this by returning val1 !== 'Hello'. Then you wouldn't need the second if statement.
| function isLongerThan(val1, val2) { | ||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (val1.length > val2.length) { |
There was a problem hiding this comment.
You could simplify this function by just returning this condition. You wouldn't need the other if statements then:
return val1.length > val2.length| } | ||
| } | ||
| return count % 2 !== 0 | ||
| // if (count % 2 == 1) { |
There was a problem hiding this comment.
It's always a good remove commented code that isn't needed anymore
| function seasonForMonth(monthName) { | ||
| // TODO: write code in this function body to pass the tests | ||
| Spring= ['March','April','May'] | ||
| Summer= ['June','July','August'] |
There was a problem hiding this comment.
Great use of arrays. Just be aware that you should create your variables like so:
const Spring = ['Match', 'April', 'May']
No description provided.