Numbers and the Math Object

let val;

// Math Object

val = Math.PI;
val = Math.round(2.4);
val = Math.ceil(2.4);
val = Math.floor(2.4);
val = Math.sqrt(64);
val = Math.abs(-3);
val = Math.pow(2,4);
val = Math.min(4, 33, 2, 5, 3, -8);
val = Math.max(4, 33, 2, 5, 3, -8);
val = Math.random();
val = Math.random() * 20 + 1;
val = Math.floor(Math.random()*20+1);


console.log(val); 
Was this page helpful?

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *