how to convert string in number with parseInt function code example
Example 1: Javascript string to int
var myInt = parseInt("10.256"); //10
var myFloat = parseFloat("10.256"); //10.256
Example 2: Use parseInt() in the convertToInteger function so it converts the input string str into an integer, and returns it.
function convertToInteger(str) {
return parseInt(str);
}