made syntax corrections in javascript
fine tuned code to allow for float division and correct arithmetic