In the above program, the user is prompted to enter lower and higher bound numbers. Therefore, to future-proof your code, you should use Number.parseInt() instead of the global window.parseInt() method. Whitespace before and after are ignored. If the first character can not be converted to a number then it returns NaN. - for negative (since ECMAScript 1). 6.022e23), using parseInt to truncate numeric values will produce unexpected results when used on very large or very small numbers. The parseFloat () function parses a string and returns a floating point number. When Number() is called as a function and not as a constructor, it performs a type conversion on the value passed as an argument, eg. Converting String to Number. Now, if you try to run this value through parseInt(), you get NaN (Not a Number): parseInt( "cb34d-234ks-2343f-00xj", 10 ) => NaN. Found inside – Page 39Numbers. In C, a common way to convert a string to a number is to use sscanf. In JavaScript, use either parseInt or parseFloat depending on whether you want the result as an integer or a floating-point value: let a let b ... Most of the time, parseInt is fine. parseInt () function in JavaScript. Found insideIf not possible, then printerror. if(isNaN(parseFloat(“test”))){ document.write("Cannot convert test string to a number."); } // -->