I'm creating a rating system, which rounds values to the nearest 0.5 and contains values between 0 and 5.
How can I iterate over an array, splitting a value (rounded to nearest 0.5), into units.
let rating = 3.7
let adjustedRating = (Math.round(rating * 2) / 2);
e.g. 3.7: ['1','1','1','1',0]
1.4 would equal ['1', '0.5', '0', '0', '0']
let starsToShow = new Array().fill('0');
starsToShow.forEach((v, i) => {
...
});
1.4 would equal ['1', '0.5', '0', '0', '0']1.4 should equal to that ?3.7should be['1','1','1','1',0]?