Using Javascript, I would like to round a number passed by a user to the nearest 10. For example, if 7 is passed I should return 10, if 33 is passed I should return 30.
Divide the number by 10, round the result and multiply it with 10 again:
var number = 33; console.log(Math.round(number / 10) * 10);