I’m looking for an output of
4.658227848101266 = 4.5
4.052117263843648 = 4.0
the closest I’ve gotten is
JavaScript
x
2
1
rating = (Math.round(rating * 4) / 4).toFixed(1)
2
but with this the number 4.658227848101266 = 4.8???
Advertisement
Answer
JavaScript
1
2
1
(Math.round(rating * 2) / 2).toFixed(1)
2