Untitled
unknown
plain_text
2 years ago
580 B
7
Indexable
function monthlySavings(arr, livingCost) {
if (Array.isArray(arr) && typeof livingCost === "number") {
let taxMoney = 0;
for (let product of arr) {
if (product >= 3000) {
taxMoney += product * 0.8;
} else {
taxMoney += product;
}
}
if (taxMoney > livingCost) {
const Savings = taxMoney - livingCost;
return Savings;
} else {
return "earn more";
}
} else {
return "Invalid Input";
}
}
const checkMoney = monthlySavings(10000, [(900, 2700, 3400)]);
console.log(checkMoney);
Editor is loading...
Leave a Comment