Sally & Holden person Objects problem


#1


Hello can anyone please help me. I am having trouble with this code. What am i doing wrong here?

https://www.codecademy.com/courses/spencer-sandbox/3/4?curriculum_id=506324b3a7dffd00020bf661#


console window: SyntaxError: Unexpected token var
error popup box: Oops, try again. There was a problem with your syntax.


function Person(name,age) {
  this.name = name;
  this.age = age;
  this.species = "Homo Sapiens";

}

var sally = 
var holden = 
console.log("sally's species is " + sally.species + " and she is " + sally.age + ". Her lastname is " + sally.lastname + ".");
console.log("holden's species is " + holden.species + " and he is " + holden.age + ". Holden's last name is " + holden.lastname + ".");

var sally = new Object();
sally.firstname = "Sally";
sally.lastname = "Bowles";
sally.age = 39;

var holden = new Object();
holden.firstname = "Holden";
holden.lastname = "Caulfield";
holden.age = 16;


#2

It seems that your code is a little scattered.
Correct order:
1.) You would create the function Person
2.) You would declare the objects (sally and holden) of person
3.) You would run your console.log statements
This code should hopefully work for you:

function Person(name,age) {
  this.name = name;
  this.age = age;
  this.species = "Homo Sapiens";
}

var sally = new Person();
sally.firstname = "Sally";
sally.lastname = "Bowles";
sally.age = 39;

var holden = new Person();
holden.firstname = "Holden";
holden.lastname = "Caulfield";
holden.age = 16;

console.log("sally's species is " + sally.species + " and she is " + sally.age + ". Her lastname is " + sally.lastname + ".");
console.log("holden's species is " + holden.species + " and he is " + holden.age + ". Holden's last name is " + holden.lastname + ".");

#3

thanks for help
so it worked but now it is saying this error
Oops, try again. Make sure to give sally the name 'Sally Bowles'
but it is there on the console window.


#4

never mind i worked that part out
thanks for your help happy coding
:smile:


#5