How to round an integer up or down to the nearest 10 using Javascript
Divide the number by 10
, round the result and multiply it with 10
again, for example:
33 / 10 = 3.3
3.3 rounded = 3
3 × 10 = 30
console.log(Math.round(prompt('Enter a number', 33) / 10) * 10);
Math.round(x / 10) * 10