ES6 - Math round() Function


Advertisements

It rounds off the number to the nearest integer.

Syntax

Math.round( x ) ;      

Parameter

  • X − represents a number

Example

console.log("---Math.round()---") 
console.log("Math.round(7.2) : "+Math.round(7.2)) 
console.log("Math.round(-7.7) : "+Math.round(-7.7))          

Output

---Math.round()--- 
Math.round(7.2) : 7 
Math.round(-7.7) : -8         
es6_math.htm
Advertisements