- 1

Can someone please help me with this challenge.The loan needs to be calculated. Amount is 15000 and percent is 20.

function main() { //get the initial amount and the interest percentage var amount = parseInt(readLine(),10); var yearPercent = parseInt(readLine(),10); var loan1 = new Loan(amount, yearPercent); //output to console console.log(loan1.yearIncome()); } function Loan(amount, percent, yearIncome) { this.amount = amount; this.yearPercent = percent; //your code goes here this.yearIncome = function() { this.yearIncome = calcYearIncome() } }; function calcYearIncome(amount,percent,yearIncome){ //complete the function to calculate yearly income this.amount = amount; this.yearPercent = percent; this.yearIncome = function(amount,percent){ return this.percent /100 * this.amount; } } This returns undefined

1st Dec 2020, 5:55 PM
Brandon Lee Banks
Brandon Lee Banks - avatar
1 Odpowiedź
+ 2
Your loan function calling has 2 arguments passing but defination has 3 arguments without defaults...... Same with calc Year Income. And loan function has not returning anything... Return a value.....
1st Dec 2020, 6:31 PM
Jayakrishna 🇮🇳