algorithm used to calculate 5 star ratings

前端 未结 14 928
挽巷
挽巷 2021-01-29 17:49

I need to calculate 5-star ratings like the one on Amazon website. I have done enough search to find what is the best algorithm, but I am not able to get a proper answer. For ex

14条回答
  •  长情又很酷
    2021-01-29 18:25

    (Total nunber of star / total number of persons who review * 5 ) * 5

    = Answer

    Fixed decimals in js to 1.

    answer.toFixed(1);

    Example the total reviews of 5 person is 20 star.

    (20/5*5)*5 = 4.0

提交回复
热议问题