Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda