3 ms·
# n < 0 means increment up to n occurrences of val # from right-to-left (backward) Presumably you mean "increment up to abs(n) occurrences", othe
by FrankBooth 14y ago
# n < 0 means increment up to n occurrences of val
# from right-to-left (backward)
Presumably you mean "increment up to abs(n) occurrences", otherwise this requirement is nonsensical.
- jazzychad 14y agoyes, 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".