r/javascript • • Mar 09 '15

Things every JavaScript developer should know

http://ilikekillnerds.com/2015/03/things-every-javascript-developer-should-know/
326 Upvotes

118 comments sorted by

View all comments

28

u/cgaudreau senior HTML9 engineer Mar 09 '15 edited Mar 09 '15

Good article. However, correct me if I'm wrong, but the provided FizzBuzz implementation appears to be incorrect. On multiples of 15, the provided solution would print "FizzBuzz Fizz Buzz".

EDIT: the author fixed it after I posted. The original example had no elses or else ifs.

-2

u/zarl0ck Mar 09 '15 edited Mar 10 '15

No, it would print FizzBuzz only and then it would cycle to the next for loop. For example if i = 15, it checks the first condition i % 15 (true) and prints FizzBuzz. It's not going to enter inside the other if conditions because it already entered in the first one.

EDIT: so the author changed the code, it was wrong when he posted the comment and it was right when I posted mine.. got mixed up, no need for downvotes