Creating A New Object


#1

var me = new me (
    me.name= "xyz";
    me.age= 23;
);  
**What is Wrong In This Code?**


#2

i really recommend you to revisit some old exercises, to see how to create/define an object. This code contains several flaws.


#3

Will you tell which exercises should I revisit?


#4

the exercise you are at, oops, sorry

look at the instructions, there are two ways to create:

var myObj = {
    type: 'fancy',
    disposition: 'sunny'
};

or:

var myObj = new Object();
myObj["name"] = "Charlie";
myObj.name = "Charlie";

your seems like a weird mixture between the two


#5

var object1= new Object();
object1.name="XYZ";
object["age"]=23;

var object2= new Object();
object2.name="abc";
object2["age"]=42;

var object3= new Object();
object3.name="cvb";
object3["age"]=67;

Will you tell me what is wrong in this?


#6

this line:

object["age"]=23;

you misspelled object1

you currently have: object1, object2 and object3, but no object me (if you are still at the same exercise)


#7

2 posts were split to a new topic: Creating a new object


#8

whenyou determine var me you should use new Object. New Object is a determiner.
var me = new Object();
me.name= "ARCH";
me.age= 29;
console.log(me);


#9

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