Sally and Holden problem


#1

https://www.codecademy.com/courses/spencer-sandbox/3/4

I'm stuck again...

here's my error message

what's wrong now?


Rectagnle
#2

... and she is " + sally.age

Ditto, for Holden.


#3

What's wrong here?


#4

You either do it like this:

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

Which is a lot to type.. or you do it like this:

var sally = new Person("Sally Bowles", 39);

This is much shorter :slight_smile:

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

This is your object constructor function to create Person objects. You can think of it as a factory of Person objects. Anytime you want to make a new one, you use the keyword new and the name of the constructor function which is Person in this case. Ex. : var me = new Person(); . You can pass arguments between parenthesis - name and age - these will become object's properties which can be accessed by dot notation like this: sally.age or this: sally["age"] - in both cases this will return 39.


#5

Edit the sentence printed out such that it includes the age of sally and holden respectively.

There is nothing in the instructions about including their names in the output.


#6

Thanks that solved my stuckness


#7

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