0

adding methods

anyone could tell me, what I am making wrong with this code please? https://code.sololearn.com/WA19A24a1961

30th May 2021, 9:21 PM
JRAMAHES
JRAMAHES - avatar
2 Antworten
+ 1
In main function change the console line to following , console.log(loan1.helloAccount()); In the above you were calling the wrong function name. -------------------------------- In calcYearIncome function , add this.yearPercent instead of yearPercent and do same for amount .
30th May 2021, 9:58 PM
Abhay
Abhay - avatar
+ 1
here you go..if anyone needs help regarding this... function main() { var prodID = readLine(); var price = parseInt(readLine(),10); var discount = parseInt(readLine(),10); var prod1= new Product(prodID, price); console.log(prod1.prodID + " price: " + prod1.price); prod1.changePrice(discount); console.log(prod1.prodID + " new price: " + prod1.changePrice(discount)); } function Product(prodID, price) { this.prodID = prodID; this.price = price; this.changePrice = function(discount) { //your code goes here this.discount=discount; var percentage=discount / 100; var mult = percentage * price newDiscount = price - mult; return newDiscount; } }
27th Aug 2021, 10:26 PM
Uzma Yasmeen
Uzma Yasmeen - avatar