This is a class project and I am first year student. I am making a tax program and one function calculates the tax bracket the value falls into and the next function will format the value, concatenating dollar signs, adding decimals with the .toFixed(2)
and will add appropriate commas with the .toLocaleString()
. I am just trying to get the value to pass through the formatMoney()
function so I can continue on with the rest of my coding. The exercise is fairly simple but being new it is difficult. Any help would be appreciated, again I just want the value to pass through the second function so I can progress with the rest of the coding which I can do, j
function calculateTax(money) {
let initAmount = parseFloat(prompt("How much do you have?"));
// The different taxes to be charged.
let tax1 = .20;
let tax2 = .15;
let tax3 = .05;
// Taking the user input and comparing it to which value if has to be calculated with.
if (initAmount <= 5) {
money = ((initAmount * tax1) + initAmount);
} else if (initAmount <= 100) {
money = ((initAmount * tax2) + initAmount);
} else if (initAmount >= 100.01) {
money = ((initAmount * tax3) + initAmount);
} else if (Number.isNaN(initAmount)) {
money = ("Invalid");
}
return (money);
}
calculateTax();
//This function will take the value of money from the calculateTax function and format as requested from client.
function formatMoney(money) {
let x = money;
console.log (x);
}
calculateTax(formatMoney(money));