Javascript roundoff number to nearest 0.5

Write your own function that multiplies by 2, rounds, then divides by 2, e.g.

function roundHalf(num) {
    return Math.round(num*2)/2;
}

Leave a Comment