Number 2/3
Rounding of Numbers
Rounding is one of the most frequent operations on the numbers. JavaScript provides several built-in functions for rounding which are given in the below table.
Function | Description | Example |
---|---|---|
Math.floor() | Rounds off to the lower limit | 3.1 becomes 3 , and -1.1 becomes -2 . |
Math.ceil() | Rounds off the number to the upper limit | 3.1 becomes 4 , and -1.1 becomes -1 . |
Math.round() | Rounds off the nearest integer when value is equal or greater than .5 | 3.1 becomes 3 , 3.6 becomes 4 , and 3.5 rounds up to 4 (the middle case) |
Swipe to start coding
A variable named price
with the assigned value of 4.7
has been given to you. Your task is to round off this variable such that we get 4
as the output.
Рішення
Дякуємо за ваш відгук!
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Awesome!
Completion rate improved to 2
Number 2/3
Свайпніть щоб показати меню
Rounding of Numbers
Rounding is one of the most frequent operations on the numbers. JavaScript provides several built-in functions for rounding which are given in the below table.
Function | Description | Example |
---|---|---|
Math.floor() | Rounds off to the lower limit | 3.1 becomes 3 , and -1.1 becomes -2 . |
Math.ceil() | Rounds off the number to the upper limit | 3.1 becomes 4 , and -1.1 becomes -1 . |
Math.round() | Rounds off the nearest integer when value is equal or greater than .5 | 3.1 becomes 3 , 3.6 becomes 4 , and 3.5 rounds up to 4 (the middle case) |
Swipe to start coding
A variable named price
with the assigned value of 4.7
has been given to you. Your task is to round off this variable such that we get 4
as the output.
Рішення
Дякуємо за ваш відгук!
Awesome!
Completion rate improved to 2single