12/17 Object is not defined


I am sure this is right I can create three objects using constructor method. I wanted to try the literal method instead for object3 but I get the error message "ReferenceError: object is not defined" and the program says "Oops, try again. Did you make object3 an object?"

var object1 = new Object();

object1.name = "Fred"
object1.age = 30

var object2 = new Object();

object.fruit = "apple"
object.colour = "green"

var object3 = {
    car: "BMW", 
    speed: 75


Originally I had my own object3, this one was copied from this forum as I could not see what was wrong and though that someone else's might run. Just in case anybody sees their own code.


object.fruit = "apple" should be object2.fruit = "apple"
object.colour = "green" should be object2.colour = "green"



First of all you need a ; after each number

Example: object1.age = 30;

Yours: object1.age = 30

Secondly you forgot to put a 2 after object on lines 8 and 9

Yours:object.fruit = "apple"

Example:object2.fruit = "apple";

And lastly you forgot object3 on lines 12 and 13.

That should fix the problems happy coding! :slight_smile:


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