Changed parseFloat to parseInt
Final plain JavaScript version