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.
Well, part of the challenge is to let the contestant figure this out by himself through reading and analyzing the given tables.
Thank you for the feedback! I tried addressing these issues. Hope the kata is better now.
Yes, I got that part. But which one is it a duplicate of?
Hello. Sorry, a duplicate of what?
This solution only works due to incomplete testing. It checks whether a is truthy. Here are some possible falsy cases in JavaScript:
false,
null,
0,
NaN,
"" (empty string),
undefined
So if you have any value other than these, such as a string like "abc" or simply the boolean true, this function wouldn’t work.
Additionally, even though this is a function expression, which is good practice, you should use the const keyword. Not using it is considered bad practice. And don’t forget the semicolon at the end.
Not entirely true since null or an empty array are falsy. Though when you get a string or a number other than 0, those are truthy. Or what if you have a variable with "true" as its value? Your solution is correct though.
#include <algorithm'> is not necessary here since the function used is part of the string library, not the algorithm library.