Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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 solution is very old,
.at
didn't exist when it was written.you can use arr.at(-1) instead of arr[arr.length -1]
This comment is hidden because it contains spoiler information about the solution
If your parameter is undefined will your code work?
I mean when arguments like Nothing, None are passed into the function will it work?
similar to mine but MAN it took me 3 whole days because i wrote lenght instead of length lol.
You don't need to reassign the array variable like this 'array = array.sort', because sort() is already mutating the array, also be afraid that it will mutate the initial array from the argument, hence better to do something like this 'const innerArray = [...array] and work with it.
Nice solution!
I attempted to use pop & shift with ternary operators, but it seems that the array would not mutate.
Instead I used the slice method to take off the edges as long as the length is >= 3 and not null.
Let me know what you think!
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...