Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Round a Number to the Nearest Integer</title> </head> <body> <script> document.write(Math.round(3.5) + "<br>"); // Prints: 4 document.write(Math.round(-5.7) + "<br>"); // Prints: -6 document.write(Math.round(7.25) + "<br>"); // Prints: 7 document.write(Math.round(4.49) + "<br>"); // Prints: 4 document.write(Math.round(0)); // Prints: 0 </script> </body> </html>