This very simple function does exactly what the title suggests, it allows you to round to any specified accuracy.

function roundTo(number, to) {
	return Math.round(number * to) / to;
}

alert(roundTo(1532, 100)); // 1500
alert(roundTo(26, 10)); // 30

If you want to get fancy, you could also modify the Number prototype for a more "integrated" solution.

Number.prototype.roundTo = function(to) {
	return Math.round(this * to) / to;
}

Related posts:

  1. JavaScript Event Handler
  2. Real-time “AJAX” JavaScript Progress Bar
  3. PHP jQuery AJAX Javascript Long Polling
  4. Converting from Prototype to jQuery
  5. PHP Dynamic JavaScript SCRIPT Insertion for Embedding