I've been sitting on this for a few days now. I'm trying to pass through values from another function into a function to complete my calculations. The calculations are update successfully on the UI using (document.getElementById("elementId").textContent = and passing through an object here)and a user is supposed to select a button to further break down the calculations by month, week ect... The button selection works however it does not see the value and I'm left with NaN.
index.js
const timeFrame = (payPeriod) => {
// console.log("HERE: ", payPeriod.target.name)
let payPeriodRate;
switch (payPeriod.target.name) {
case 'year':
payPeriodRate= updateValuesByPeriod (1)
break;
case 'month':
payPeriodRate = updateValuesByPeriod(12);
console.log ("month:", payPeriodRate)
break;
case 'biweekly':
payPeriodRate = updateValuesByPeriod(26);
// console.log ("biweekly:", payPeriodRate)
break;
case 'week':
payPeriodRate = updateValuesByPeriod(52);
// console.log ("week:", payPeriodRate)
break;
case 'day':
payPeriodRate = updateValuesByPeriod(260);
// console.log ("day:", payPeriodRate)
break;
case 'hour':
payPeriodRate = updateValuesByPeriod(1950);
// console.log ("hour:", payPeriodRate)
break;
}
}
method 1:
export const updateValuesByPeriod = (divisor) => {
console.log ("updateValuesByPeriod:", divisor
document.getElementById("salaryValue").textContent = document.getElementById("salaryValue").textContent / divisor
method 2:
const updateValuesByPeriod = (divisor) => {
console.log ("updateValuesByPeriod:", divisor)
let uiValues = calculateTax();
document.getElementById("salaryValue").textContent = `- $${uiValues.grossIncome}` / divisor