calculate rating out of 5

JavaScript
(5*252 + 4*124 + 3*40 + 2*29 + 1*33) / (252+124+40+29+33) = 4.11 and change

Source

Also in JavaScript: