32.Customizing Constructers


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


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";


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:


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");



:smile: :smile:

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


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"];


This is the link shown for the excercise.



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


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];

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

Hope this helps! :slight_smile:


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