What is the p variable for in Exercise 13


#1


function Person(name,age) {
  this.name = name;
  this.age = age;
}
// a function that prints the name of any given person
var printPersonName = function (p) {
  console.log(p.name);
};

var bob = new Person("Bob Smith", 30);
printPersonName(bob);

// make a person called me with your name and age
// then use printPersonName to print your name
var me = new Person("Jules V", 22);
printPersonName(me);


#2

p is the function parameter, you could call this anything you like, but this way you can pass instances of your object (bob, me) into your printPersonName function


#3

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