re: Factorial Algorithm: ES5 & ES6 JavaScript Solutions VIEW POST


Nice explenation on factorial. There is just tiny problem.

Every time I see


I cringe a bit.
Please stop this and write

if(i > 0)

We do not need to save bytes anymore and it is much more expressive. Also just checking whether integer is not 0 is error prone.

It might seem like I'm being extra pedantic (I sure as hell am), but there is a reason. In the small examples this won't make a difference. A problem arises when this kind of behaviour slips in to real world code. There this can go undetected and cause errors. This is why I always try to be as expressive as possible, even in academic examples and coding dojos.

code of conduct - report abuse