Converting math equation from PHP to Javascript (Jquery)

I’ve been working on getting a Coefficient of Variation equation ported from PHP to Javascript, but can’t seem to get it working.Original PHP script:// define variables, strip spaces$weights...