Math.floor(x);
+3.5 => +3.0
-3.5 => -4.0
+3.5 => +3.0 using Math.floor()
-3.5 => -3.0 using Math.ceil()
//standard round function, except round .5 down instead of up
function roundHalfDown(num) {
return -Math.round(-num);
}
roundHalfDown(1.5);// 1
roundHalfDown(1.6);// 2
// Will round innerHTML value to 2
document.getElementById("myId").innerHTML = Math.floor(2.9);