javascript round half even

by hairinwind

HTML

<div id='result'>result</div>

JavaScript

$("#result").text('');

var a = 82.5;
var round = function (x) {
  return 2 * Math.round(x / 2);  
};

$("#result").append(round(82.5));
$("#result").append("<br/>").append(round(7.5));
$("#result").append("<br/>").append(round(3.5));
$("#result").append("<br/>").append(round(2.5));