Please help! i just started learning objects ecc.. i didn't want to go ahead, because i wanted to really understand the Objects on javascript. So i tried to write some codes of an objects with hourly pay,weekly hours,expenses,overtime and 3 functions.
var monthlyPay = {
//hours per week
hourWeek: 40,
//pay per hours
hourlyPay: 10,
//all the monthly expenses
mothlyExpenses: 120,
//additional hours of work
overtime: 7,
//function that calculates the bonus based on the overtime and hourlyPay plus 4
calculateBonus: function(){
this.Bonus = this.overtime * (this.hourlyPay + 4);
},
//function that calculates the total monthly pay
calculatePay: function(){
this.Pay = this.hourWeek * this.hourlyPay + this.Bonus;
},
//function that calcutes the remaining money
calculateMoney: function(){
this.Money = this.monthlyExpenses - this.Pay;
},
};
monthlyPay.calculateMoney();
monthlyPay.calculateBonus();
monthlyPay.calculatePay();
console.log(monthlyPay);
It runs with no error, but when i look at the browser console the Money property has a value of NaN. Thanks in advance for answering!!