JavaScript: Round up an integer value to the next multiple of 5
JavaScript Math: Exercise-28 with Solution
Round Integer to Next Multiple of 5
Write a JavaScript function to round up an integer value to the next multiple of 5.
Test Data:
console.log(int_round5(32));
35
console.log(int_round5(137));
140
Sample Solution:
JavaScript Code:
Output:
35 140 145
Visual Presentation:
Flowchart:

Live Demo:
For more Practice: Solve these Related Problems:
- Write a JavaScript function that rounds an integer up to the next multiple of 5 using arithmetic operations.
- Write a JavaScript function that computes the next multiple of 5 for a given integer and handles negative numbers appropriately.
- Write a JavaScript function that rounds a number to the nearest multiple of 5, biasing the result to always round up.
- Write a JavaScript function that calculates the remainder of a number when divided by 5 and adjusts the value to the next multiple.
Go to:
PREV : Calculate Degrees Between Two Points.
NEXT : Convert Positive Number to Negative.
Improve this sample solution and post your code through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.