Maths: strings to integers

Maths: strings to integers

string_value = "40";
integer_value = parseInt(string_value);
alert('Integer Value = '+integer_value); // will return 40
new_string_value = "40.666"; //change the decimal point to whatever you want
new_integer_value = parseInt(new_string_value);
alert('New Integer Value = '+new_integer_value); // will return 40
Comments are closed.