13. How do Classes Help Us?


#1



https://www.codecademy.com/courses/objects-ii/2/3?curriculum_id=506324b3a7dffd00020bf661


Hi
I am not sure why I am wrong but it saying that I didn't create a person called me which I am pretty sure I did.


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 jack= new Person("me", 18);
printPersonName(jack);


#2

your person is called jack, not me


#3

ok I changed it and it didn't matter
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 jack= new Person("Jack", 18);
printPersonName(jack);


#4

you already called your person jack, you should have called the person me


#5

Errhhmmm... @stetim94 was saying you should do this:

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("Jack", 18);
printPersonName(me);

#6

yep, i indeed meant that. If the comments says it:

// make a person called me with your name and age

and then he calls the person jack


#7

OK it worked thanks it threw me off a bit