parseInt()
parses a string and returns a whole number. Spaces are allowed. Only the first number is returned.
This method has a limitation though. If you parse the decimal number, it will be rounded off to the nearest integer value and that value is converted to string. One might need to use parseFloat()
method for literal conversion.
myString = '129'
console.log(parseInt(myString)) // expected result: 129
a = 12.22