Relative Content

Tag Archive for javascriptrecursionbinarydecimal

How to check if the value returned by the parseInt() function is a number or not

I’m building a decimal-to-binary number convertor. I need to check if the value returned by the parseInt() function is a number or not. I know that you can use the isNaN() function. This function takes in a string or number as an argument and returns true if it evaluates to NaN. I need the second condition in my if statement to use the isNaN() function to check if the value returned by parseInt() is NaN. I also want to consider only positive numbers to convert, I want to add a third condition in the if statement to check whether the number is less than 0.