So taking it a step further I decided to create a function that would round a number to the nearest 10, 100, 1000 or whatever value is entered. If this value is less than 0 then do the reverse by multiplying and dividing the number by the given value of accuracy. Here is the function.
1 2 3 4 5 6 7 8 9 10 11 12 13
Here are some tests of the function.
alert( roundNearest(12345, 1000) ); // 1200 alert( roundNearest(12345.1234, -100) ); //12345.12
This function can be simplified a little by putting all of the calculations onto one line.