javascript - Object constructor syntax error -


in process of learning js... it's mai second week first day of js , have big problems syntax

function customer(name, street, city, state, email, balance) {     this.name = name;     this.street = street;     this.city = city;     this.state = state;     this.email = email;     this.balance = balance;     this.paydownbal = function(amtpaid) {         this.balance -= amtpaid;     };     this.addtoba = function(amtcharged) {         this.balance += amtcharged;     }; } var cust2 = new customer("sally smith", "234 main ", "pittsburgh", "pa", "ssmith@aol.com", 0.00);  cust2.addtobal(15.50);  customer.prototype.iscreditavail = true;  customer.prototype.tostring = function() {     return this.name + " lives @ " + this.street + " in " +         this.city + " " + this.state + " email : " + this.email +         " , has balance of $ " + this.balance.tofixed(2) + "creditworty : " + this.iscredavail; } document.write(cust2.tostring()); 

i can't find error...can helped please ?

you made simple mistake. defined addtoba() function , calling function addtobal() not defined.

change line 17 call function addtoba(). (or change function declaration addtobal()).


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -