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.
if you omit curly brackets when using arrow function you don't have to use "return" keyword
1 instance of have to paint a "0", 9 instances of having to paint a "1", 6 instances of having to paint a "2", etc.
Sure, no worries. In terms of your solution, it does what it's designed to do (and passes all the tests) so is correct and valid, I found it pretty obvious what it was doing (you'd be amazed how rare this can sometimes be), so it is a good and viable solution. The only thing I would say is you don't need needless comments. Commenting that you've created an empty variable for example, doesn't add anything IMO.
In practice, given your's has a higher complexity class than an optimal solution, then in the real world you would probably go with the more optimal solution, especially here since it's trivial to do so. That said it depends on how much of a bottleneck it actually is as to whether you'd bother (i.e. if you knew for certain this would only ever be called with arrays of 10 elements of less then optimising it would be unnecessary, just as an example). There is a saying: premature optimisation is the root of all evil.
I've ran it locally and this solution gives 3 for input [3, 4, 5, 6, 3] - which is the correct answer. How are you running the function? (I just copied and pasted into a file and ran it using Node)
This comment is hidden because it contains spoiler information about the solution
This solution is an arrow function; in an arrow function the return is implied. The syntax does not use "return". Try finding info on arrow functions.