News for hackers. Stuff that matters.
Re:Array Iteration Interview Problem by jazzychad on Wednesday August 01, 2012 @08:27PM (#4326527)
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.
Re:Array Iteration Interview Problem by spicyj on Wednesday August 01, 2012 @08:29PM (#4326535)
You 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.

Re:Array Iteration Interview Problem by revelation on Wednesday August 01, 2012 @08:31PM (#4326542)
In your code, it is actually completely unnecessary. You have already established that n is < 0, so you could just do "n = -n".