Your reply is 6 months old, so I assume you figured it out, but for those reading and wondering the same.
||[] this part of the code, if no match was found, it returns an empty array and if you call .length on an empty array, it will return 0
I just tested it again in codewars with 10,000,000,000 and it still works fine. I also tried with other several higher numbers and it always works fine and returns the expected value:
very concise 😀👍. It never crossed my mind.
wow!
Even though I also consider this as clever, wouldn't this be best practice (or maybe better practice)?
This comment is hidden because it contains spoiler information about the solution
Same!
I am so disappointed in myself right now.
Excellent solution
This comment is hidden because it contains spoiler information about the solution
came to the comments for this. Thanks!
This is a clever solution
Insane
I see... I have to go back to studying.
Your reply is 6 months old, so I assume you figured it out, but for those reading and wondering the same.
||[] this part of the code, if no match was found, it returns an empty array and if you call .length on an empty array, it will return 0
I just tested it again in codewars with 10,000,000,000 and it still works fine. I also tried with other several higher numbers and it always works fine and returns the expected value:
Here you can try the tests:
This dude must be a scientist in NASA
Loading more items...