I'm using Math.sign() to check whether or not the number is positive or negative. If it never gets to my if statement, then how is it updating the variable and returning the string the correct number of times?
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.
I'm using Math.sign() to check whether or not the number is positive or negative. If it never gets to my if statement, then how is it updating the variable and returning the string the correct number of times?
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.
So, if (Math.sign(num)) { . . . } could be replaced with if (true) { ... } in your code without changing any answer?