I'm looking for an output of
4.33 = 4.5
4.5517263843648 = 5
Using the Math.round function in javascript. I've tried a few methods but neither seem to work.
I'm looking for an output of
4.33 = 4.5
4.5517263843648 = 5
Using the Math.round function in javascript. I've tried a few methods but neither seem to work.
Try to use,
function test(val) {
var x = Math.floor(val);
return (val - x) > 0.5 ? Math.ceil(val) : (x + 0.5);
}