var roundedValue = Math.round(myValue / 5) * 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.
Snippet Viewed 2698 times.
- Get some recognition & a link back to your site.
- Create your own code library.
- Help your fellow developers, as they have helped you.