32.Customizing Constructers


#1

I did as you guys said read it three times but nothing...

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

Make sure to use the Book constructor to create the_hobbit


var the_hobbit = new Book(pages, author);
   this.pages = 320;
   this.author = "J.R.R. Tolkien";

#2

Err.. If constructor, I guess you should be doing this:

var the_hobbit = new Book();
the_hobbit.pages = 320;
the_hobbit.author = "J.R.R. Tolkien";

Hope this helps! :slight_smile:


#3

It did not accept yours cause it said that it should be on one line only. So I got a different route and it accepted the code following below:

~~~~~~~~~

var the_hobbit = new Book(320, "J.R.R. Tolkien");

~~~~~~~~~


#4

:smile: :smile:

Please explain how and why that is? I'm curious.


#5

Hi I cant pass this

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};
var mary = {
firstName: "Mary Johnson",
lastName: "Jones",
phoneNumber: "(650) 888 - 88887",
email: "mary.johnson@example.com"
}

var contacts =["bob", "mary"];
console.log(mary.phoneNumber)

#6

This is the link shown for the excercise.

https://www.codecademy.com/courses/building-an-address-book/0/2?curriculum_id=506324b3a7dffd00020bf661#


#7

And my error:
"Make sure that mary is the second object in contacts"


#8

To start with, that was why I wanted you to explain your last code. Building a constructor is pretty easy.

You should be doing this:

var contacts = [bob, mary];
console.log(contacts[1].phoneNumber);

What the last line does is to console.log out Mary's phone number.

Hope this helps! :slight_smile:


#9

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