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.
Can you explain why?
I know right. That's just way too many lines😂!!!
Not anymore, no. I was pointing out that the kata's tests were horrible. It's been fixed.
@koushik72, magic constants are numbers which appear in a program.
Often repeatedly.
For example, if you had a conversion program and used the conversion factor as a number everywhere, that would be a magic constant.
Having magic constants in a program is generally a bad thing because the number doesn't express what it is being used for. And is vulnerable to typos.
It's better to make a constant variable equal to the number, e.g.,
CONVERSION_RATE
, and use it instead, making the code clearer.I don't think it applies here, as 100 being used for percentage calculations is well known and it is hard to come up with a variable name for that 100.
I am not good in js. Can you please explain what is magic constants? Thanks.
Concerning code duplication, I have submitted a new solution that you might like better.
As for magic constants, are you talking about the value
100
? If it is not obvious that it is used to compute a percentage, it could be explained in a comment.Indeed, I would prefer the simplified condition to the one in this case. It will be slightly more efficient code, it will be shorter code, etc.
This comment is hidden because it contains spoiler information about the solution