Globals and Numbers and Maths
Video
JavaScript Notes
JavaScript
// Globals and Numbers and Math.
let r = parseInt("234.234", 10); // converts to Integer (i.e. 234), to base 10
console.log(r);
let num = 234.234234232;
let str = "234.234234232";
r = Number.parseInt(str);
r = Number.parseInt(num);
r = num.toFixed(2);
r = Math.round(num);
r = Math.floor(num); // round down
r = Math.ceil(num); // round up
r = Math.random(); // random number between 0 and 1
r = Math.max(97, 77, 7, 37, 47, 57); // returns the largest number (i.e. 97)
Feedback
Submit and view feedback