Math.round

round — Rounds to the closest whole number.

Description

Math.round(number number)

Parameters

Name Description Type Default Optional
number number No

Examples

Example #1 – round example
console.log(Math.round(1)); // 1 console.log(Math.round(1.0)); // 1 console.log(Math.round(1.2)); // 1 console.log(Math.round(1.49)); // 1 console.log(Math.round(1.5)); // 2 console.log(Math.round(1.8)); // 2 console.log(Math.round(2)); // 2

See also

External references