26. Pa ssing Arguments (says title has censored word in it thats why there is a space)


#1

pls help me

says i have syntax error

function Person(first,last,age) {
   this.firstname = first;
   this.lastname = last;
   this.age = age;
   var bankBalance = 7500;
  
   this.askTeller = function(pass) {
     if (pass == 1234) return bankBalance;
     else return "Wrong password.";
   };
}

var john = new Person('John','Smith',30);
/* the variable myBalance should access askTeller()
   with a password as an argument  */
var myBalance === john.askTeller(1234);
console.log(myBalance)

SyntaxError: missing before statement


#2

var myBalance === john.askTeller(1234);

Here you need to use assign operator = not comparison.


#3

Thanks. It worked :grin:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.