Round number to nearest .5 decimal

So this answer helped me. Here is a little bit o magic added to it to handle rounding to .5 or integer. Notice that the *2 and /2 is switched to /.5 and *.5 compared to every other answer.

/*
* @param {Number} n - pass in any number
* @param {Number} scale - either pass in .5 or 1
*/
var superCoolRound = function(n,scale) {
    return (Math.round(n / scale) * scale).toFixed(1);
};

It's rather simple, you should multiply that number by 2, then round it and then divide it by 2:

var roundHalf = function(n) {
    return (Math.round(n*2)/2).toFixed(1);
};

This works for me! (Using the closest possible format to yours)

   rating = (Math.round(rating * 2) / 2).toFixed(1)

(Math.round(rating * 2) / 2).toFixed(1)