Variables in JavaScript are typically passed by value (except for objects and arrays, which we'll talk about later and are passed by reference). "Pass by value" means that when a variable is passed into a function, that function receives a copy of the variable. The function is unable to mutate the caller's original data.
let x = 5;
increment(x);
console.log(x);
// 5
function increment(x) {
x++;
console.log(x);
// 6
}
Fix the bugs in the monthlyBillIncrease and getBillForMonth functions.
monthlyBillIncrease: Returns the increase in the bill from the previous to the current month. If the bill decreased, it should return a negative number.getBillForMonth: Returns the bill for the given month.It looks like whoever wrote the getBillForMonth function thought that they could pass in the bill parameter, update it inside the function, and that update would apply in the parent function (monthlyBillIncrease). They were wrong.
Change the getBillForMonth function to explicitly return the bill for the given month, and be sure to capture that return value properly in the monthlyBillIncrease function.
The function signature for getBillForMonth should only take 2 parameters once you're done.