26. Passing Arguments


#1


I've done exactly what the instructions say "Create a new variable called myBalance that calls the askTeller function with a password argument, 1234."

Yet my code (all I've typed is all that's below the comments) does not work.


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 = this.askTeller(1234);


#2

It should be var myBalance = john.askTeller(1234); since John is the person. =D


#3

Awesome that works, thank you!


#4

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