Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
JavaScript keeps concatenating numbers in a for loop even after parsingFloat()

I am trying to calculate sum of multiple fields in a table. I'm using a for loop to do this but it only returns the numbers in concatenating form. I have used parseFloat but it doesn't work. Result shows up like this 174.3294.92164.4162.5.

enter code here


   function grossAmount(){
    var grossPay = document.getElementsByClassName('grossPay');
    var cppDeduct = document.getElementsByClassName('cppDeduct');
    var eiDeduct = document.getElementsByClassName('eiDeduct');
    var fedTax = document.getElementsByClassName('fedTax');
    var grossResult = document.getElementById('grossAmountCRA');
    var cppGross = document.getElementById('cppCRA');
    
    for (let i = 0; i<grossPay.length; i++){
        grossResult.innerHTML += parseFloat(grossPay[i].innerHTML);
    }
    
    for (let i = 0; i < cppDeduct.length; i++){
        cppGross.innerHTML += parseFloat(cppDeduct[i].innerHTML);
        
        
    }
    
    
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!