Standard Library Utilities
Parsing Numbers
Turn numeric text into values that can be calculated.
Parsing Numbers
parse_numbers.js
const text = "12.5";
const whole = Number.parseInt(text, 10);
const decimal = Number.parseFloat(text);
const doubled = decimal * 2;
console.log("text=" + text);
console.log("whole=" + whole);
console.log("doubled=" + doubled);
parse-numbers
`Number.parseInt` reads an integer part, and `Number.parseFloat` keeps the decimal part. Parsed numbers can feed ordinary arithmetic.