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);
CodePudding user response:
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