How to round a number in JS?

JavaScript: How to round a number in JS?

Use the Math.round(123.45) method to round numbers in Javascript.

If you want to round up or down to that integer, use ceil or floor

For example, Math.ceil(1.01) returns 2. Ceil is short for ceiling.

Math.floor(1.99) returns 1

webdevetc profile pic

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This ( is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.


Comments and discussion about How to round a number in JS?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the JavaScript language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How to add the CSRF (Cross-site request forgery) token in Laravel?

What is Bubble sort, and how to write an implementation of it in PHP

How to check if an object or variable is an array, in JS?

How to get the type of a variable in JS?

What are PHP's PSRs?

What are the main error types in PHP

What kind of database field type should you (normally) use for foreign keys?

How to access the Laravel's route parameters outside of the controller?

How to select what columns to return when calling ::all()

How to make Apache force download of files (in .htaccess)