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.
Where i is an int.
i
To round down to the nearest multiple of 10 i.e.
11 becomes 10 19 becomes 10 21 becomes 20
parseInt(i / 10, 10) * 10;
To round up to the nearest multiple of 10 i.e.
11 becomes 20 19 becomes 20 21 becomes 30
parseInt(i / 10, 10) + 1 * 10;