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.
Non-zero numerical values are "truthy" in JS and 0 s "falsy":
https://developer.mozilla.org/en-US/docs/Glossary/Truthy
This comment is hidden because it contains spoiler information about the solution
tbh, best practise would be to use a language with a proper strict type system if you want to be sure to avoid these issues. All else is a bandaid/workaround.
This is a little pedantic, it's a conditional expression, which is close enough to being an if statement that most people would know what you mean and not care that he called it an if statement.
Ha, you're quite right. How weird, though not at all surprising given how weird JS can be.
But yes, in Javascript, falsey values are things like 0, "", [], etc. Everything else is truthy, including negative numbers.
It isn't surprising if you think about it, a negative value is still "something" but 0 is "nothing".
All non-zero integers evaluate to true, including negatives.
But in this case: -1 % 2 actually evaluates to 1, since -1 isn't in the set of Z2. The remainder of -1 divided by 2 is one.
Exactly what I was thinking