Constants

Rounding & Truncation

console.log(Math.floor(4.9)); // 4
console.log(Math.ceil(4.1)); // 5
console.log(Math.round(4.5)); // 5
console.log(Math.trunc(-4.9)); // -4

Random Number Generation

function getRandomInt(min: number, max: number) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}
console.log(getRandomInt(1, 10)); // e.g. 7

Min & Max

let numbers = [3, 7, 2, 9, 5];
console.log(Math.max(...numbers)); // 9
console.log(Math.min(...numbers)); // 2

Power & Roots