How do you round the number 7.25, to the nearest integer?
-
round(7.25)
-
rnd(7.25)
-
Math.round(7.25)
-
Math.rnd(7.25)
Math.round() is a built-in JavaScript method that rounds a number to the nearest integer. Options A and B use non-existent functions, and option D uses a non-existent Math.rnd() method. JavaScript's Math object provides round(), ceil(), floor(), and other mathematical functions as static methods.
To round a number to the nearest integer, you can use the Math.round() function.
Option A) round(7.25) - This option is incorrect because round is not a valid function. The correct syntax is Math.round().
Option B) rnd(7.25) - This option is incorrect because rnd is not a valid function. The correct syntax is Math.round().
Option C) Math.round(7.25) - This option is correct. The Math.round() function rounds the number to the nearest integer.
Option D) Math.rnd(7.25) - This option is incorrect because rnd is not a valid function. The correct syntax is Math.round().
The correct answer is Option C. This option is correct because it uses the Math.round() function to round the number 7.25 to the nearest integer.