3 ms·
yes, that is technically correct (the best kind), however everyone has understood it as intended so far. I also state it like that so as not to give a tip that
by jazzychad 14y ago
yes, that is technically correct (the best kind), however everyone has understood it as intended so far. I also state it like that so as not to give a tip that abs() might be helpful to them down the line.
- spicyj 14y agoYou could also say -n if you didn't want to say abs. I found the problem confusing because of how it was written. Also, unless I'm mistaken, you can lose the "if (n === 0)" case completely.
- revelation 14y agoIn your code, it is actually completely unnecessary. You have already established that n is < 0, so you could just do "n = -n".