26. Passing Arguments


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);


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


Awesome that works, thank you!


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