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.
In theory this is the best practice because it makes use of existing and tested code that's clearly available here.
Hi! Thanks for the replies. Yes, I did try looking through the documentation online. I saw a few different ways of approaching the problem, but some of them involved code that I haven't learned about yet. I tried rearranging my if/else if statements and that did the trick...
Have you tried to search for documentation online? Just something like "check empty array JavaScript", "check null array JavaScript"?
You're doing it wrong. Try reading the posts below.
P.S.: your current code works.
Apparently, a lot.
This comment is hidden because it contains spoiler information about the solution
Not an issue ~~ There's this in description too
If the input is an empty array or is null, return an empty array.
The description quite literally says "given an array of integers", yet one test gives
null
as the input, which results inTypeError: Cannot read property 'length' of null
when correctly assuming that you always get an array (as per description) and merely need to test for its length.Solutions like this one that modify the arguments should be banned. This causes unintended sideeffects by modifying any objects passed. Please clone objects before modifying!