DEV Community

Discussion on: Basic Algorithm Scripting in JavaScript

 
toddster79 profile image
Todd Carlson

I guess I only call Math.sign for the positive case, the else statement returns the empty string for the other cases. I still don't see how this isn't a correct solution to the problem. I check to see if it is a positive number with Math.sign, if it is the variable gets updated and returned the correct number of times. In all other cases, negative or zero, it returns an empty string.

Thread Thread
 
pentacular profile image
pentacular

So, if (Math.sign(num)) { . . . } could be replaced with if (true) { ... } in your code without changing any answer?