Which of the following functions returns the number downwards to its nearest?

JavaScript Math.round( ) function

Improve Article

Save Article

Like Article

  • Last Updated : 29 Nov, 2022

  • Read
  • Discuss
  • Courses
  • Practice
  • Video
  • Improve Article

    Save Article

    JavaScript Math.round( ) function is used to round the number passed as a parameter to its nearest integer. 

    Syntax:

    Math.round(value)

    Parameters:

    • value: The number to be rounded to its nearest integer.

    Example 1: Rounding Off a number to its nearest integer

    To round off a number to its nearest integer, the math.round() function should be implemented in the following way: 

    Javascript




    Number after rounding : 6
    4

    Output:

    Number after rounding : -6

    Example 3: Math.round() function, when a parameter has “.5” as a decimal

    Below program shows the result of Math.round() function when the parameter has “.5” as a decimal. 

    Javascript