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

142
Views
Get the SUM of all inputted numbers in useState

I am currently adding the semiMonthlyRate, HolidayPay, SpecialHolidayPay, NightDiff and the overtimePay but the result is not the one that i've expected, all the inputed data I've put it in useState since the exercise doesn't need a database.

this is the link of my project. https://codesandbox.io/s/plus-minus-button-forked-e6wrf?file=/src/App.js

i've try to code this but it was not the expected output, I've used useEffect hook.

setTotalEarnings(semiMonthlyRate + holidayPay + specialHolidayPay + calculateNightDiff + calculateOvertime);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Change your code where you do addition to this

      parseFloat(semiMonthlyRate) + parseFloat(holidayPay) + parseFloat(specialHoliday) + parseFloat(nightDiff) + parseFloat(overtime)

By Default the values of text input are treated as string so need to convert them. If you want to avoid this simply use <input type="number">, for taking input of numerical values

about 4 years ago · Juan Pablo Isaza Report
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!