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.
args are mutable, so you can just use n directly and decrement it in your loop without need for an extra variable
Definitely looks more "code-y" but uses extra memory for variables and unnecessary loops.
while
numbers.reduce
would allow for scores of any length, that is not necessary for the prompt requirements and is actually overengineered for this task.This comment is hidden because it contains spoiler information about the solution
I also thought of using a switch, but as you can see by the comments here, using switch(true) and then doing evaluations in each case is kind of an anti-pattern that can be hard to read and debug.
I would avoid and look for one of the other conditional options in this board.
destructuring scores into an array inthe function definition was a good move
Agree.
Remove the else and just return the else value, since the if condition returns if hit.
Also, pairing an arrow function with a ternary will allow you to return the value directly and keep it even more concise
This comment is hidden because it contains spoiler information about the solution
This is correct and achieves the desired result, but: