Closed jamesplease closed 9 years ago
I prefer the change described here - I think it's better to change the code making it more explicit rather than adding comments.
thanks for your feedback @davecocoa !!
@ashleygwilliams want to whip up a PR implementing the explicit ===
operators, or would you like me to give it a try?
@jmeas i've got it, i'll try to get it done today.
Sounds good!
https://github.com/rmurphey/js-assessment/pull/95 demonstrates out a potential area of confusion in the fizzbuzz solutions, which #26 attempts to address.
The issue is that the modulo operator returns 0 when it's not divisible, which evaluates to false in the if statement. The solutions, therefore, test the opposite of what one would expect.
To describe it another way, when
num % 5
is true, the expression evaluates to false.26 does a good job at trying to clarify this with words, but @ashleygwilliams proposed a code change that makes the code itself more expressive.
The idea would just be to do something like:
It may even be simpler by just having one expression in each
if
. I'm not sure, 'cuz I don't have the tests open. But, you know, the idea is to use===
to make the code more explicit.Either this solution or #26 would close this issue. At the moment, I can't say which proposal I prefer!