31/33 , properties


#1



getting error( Oops, try again. It looks like you didn't save snoopy's age into age!
)

var snoopy = new Object();
snoopy.species = "beagle";
snoopy.age = 10;

// save Snoopy's age and species into variables
// use dot notation for snoopy's species
var species = snoopy.age;
var species = snoopy.species;
    
var age = snoopy["age"];
var age = snoopy["species"];


#2

@sudeepsagarr,
With your last code-line
var age = snoopy["species"];
you are destroying the previously set age varaible by re-assigning the age with species.....


#3

I did not get you. Can you please elaborate ?


#4

@sudeepsagarr,
Change your

into

// save Snoopy's age and species into variables
// use dot notation for snoopy's species
var age = snoopy.age;
var species = snoopy.species;


#5

Thank You :slight_smile:


#6

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