JavaScript Round to the nearest multiple of 5

You can easily round to the nearest multiple of five by first dividing your value by 5, then rounding it. Afterwards, just multiply by 5 to get your answer.
var roundedValue = Math.round(myValue / 5) * 5;
Posted by
Snippet Viewed 2698 times.

Share your JavaScript code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.


Submit | Browse

Most Recent javascript snippets

Most Viewed