4 ms·
Wouldn't the simpler, faster and more appropriate syntax be if (N > 50 || N < 1) ??
by BuzzKilla1960 13y ago
Wouldn't the simpler, faster and more appropriate syntax be
if (N > 50 || N < 1) ??
- angersock 13y agoI think they may be trying something clever with the truthiness of N there...
- imslavko 13y agoIt would be a simpler and shorter piece of code. Not sure why it would be faster though. Anyways, the point was in the behavior of `limit` which is easy to miss.
- BerislavLopac 13y agoNo it wouldn't, because -30 is supposed to work the same as 30, so you want to convert the sign to positive first. Personally, I'd use something like: if (!N || Math.abs(N) > 50 ) { N = 50 };