Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda