parseInt() or parseFloat() are functions in JavaScript which can help you convert the values into integers or floatfloats respectively .
Syntax : -
Syntax:
parseInt(string, radix); parseFloat(string); string : - it can be either a variable or a string itself .
radix :- (Optional, but highly encouraged) It is a numeric value between 2 - 36 , it represents the numeric system to be used.
- string: the string expression to be parsed as a number.
- radix: (optional, but highly encouraged) the base of the numeral system to be used - a number between 2 and 36.
Try this : -
Example:
var x = prompt("Enter a Value","10" "0"); var y = prompt("Enter a Value", "10""0"); var num1 = parseInt(x); var num2 = parseInt(y); After this you can perform which ever calculations you want on them .