If the execution in your if statement is a return, you don't need an else block after it, because the function will not continue to execute once it's returned.
And with the spread operator, you can now simplify the use of Math.min and Math.max to Math.min(...array) and Math.max(...array), respectively.
Thanks, you're correct!
kudos for correcting the parameter casing to pascal
rather than using breaks, just return inside each case. Cleaner, more readable.
default message should read "0-9" right?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This is so smart. Thank you for sharing that. Also good point on the effects of sorting for larger arrays
This comment is hidden because it contains spoiler information about the solution
If the execution in your
if
statement is a return, you don't need anelse
block after it, because the function will not continue to execute once it's returned.And with the spread operator, you can now simplify the use of Math.min and Math.max to
Math.min(...array)
andMath.max(...array)
, respectively.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...