1 Shut the stop!


#1

//Create the object called cashRegister
//and initialize its total property

function cashRegister(total){
this.total=0;
};

//Using dot notation change the total property
cashRegister.total=2.99;

It doesn't accept my Object. I don't know why if it was the syntax used in the past excercises!


#2

Wait, is it because :
function cashRegister(total){
this.total=0;
};

Is the constructor syntax?

So if I'm not creating several object should I just write:
var cashRegister={
total:0,
};

???


#3

You need to use the object literal notation, not a function.


#4

Try this code:

//Create the object called cashRegister
//and initialize its total property
var cashRegister = {
total: 0
}
//Using dot notation change the total property
cashRegister.total = 2.99;


#5

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