Where's the problem


#1


https://www.codecademy.com/courses/spencer-sandbox/5/2?curriculum_id=506324b3a7dffd00020bf661#


Oops, try again. It looks like you didn't save snoopy's species into species


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 = {
    species: "beagle"
};
// use bracket notation for snoopy's age
var age = snoopy['age'];
//Here's where my problem is supposed to be
var species = {
    species: "beagle"
};

I've tried both ways to write an Object but they both come out with the same problem


#2

It says to use dot notation to save snoopy.species to a variable called species!


#3

I know but the code is wrong with the dot notation

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

#4

here's the problem again

Oops, try again. It looks like you didn't save snoopy's species into species

here's the code

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

#5

Well understand it ..

suppose I created an object..call someObj..

var someObj = new Object();

and I assigned some properties to it.

someObj.xProp = "one";
someObj.yProp = "two";

and If you say to save xProp's value to a variable called say col using dot notation..
I will do this..

var col = someObj.xProp ;

#6

nice edit bro

I'm just getting annoyed with the level of difficulty for me on these lessons


#7

also part of the problem that I'm not getting this done faster is the fact I stopped 75% through and did a bunch of other types of coding. And I need a string not numbers


#8

I think revision of previous chapters theory will help ?
(I made them strings,Actually you need to understand the concepts of how we create Objects and access the properties(values))


#9

I have them open in a different tab but that's no help because the code is correct, but it isn't "saving to species" :angry:


#10

Your code is not correct!

var species = {
    species: "beagle"
};

By doing this you're creating a new Object but you have asked to save snoopy.species to a variable species.

Also this line of code..
snoopy.species = "beagle";

species here is a key .


#11

so i write

    species.snoopy = "beagle";

?


#12

How do I save the species to species?


#13

Here is my error now
Oops, try again. It looks like you didn't save snoopy's species into species

here's the code

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

and here's the console

"beagle"

how do I get the age to log too? could I just get an example for the age variable?


#14

Back to your old code...

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

//This part of code needs to be fixed...
var species = {
    species: "beagle"
};

// use bracket notation for snoopy's age
var age = snoopy['age'];

If you look at the hint you will see it says..

Snoopy is an object which have 2 pairs of key:value...
if you run that part of code in your chrome console and test it..

You can see your snoopy object have two key:value pairs..
now read the instructions..

// use dot notation for snoopy's species

we can access snoppy's age doing this...

snoopy.species and this is actually "beagle"

what you have to do now is to save this value inside a variable called species.
As variable name and key name is same so I think you got confused?

I again suggest to revise the previous section,If you don't get anything. I will explain.


#15

I commented out everything except the top and the code doesn't change


#16

Can you post your current code?


#17

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 = new Object();
snoopy.species = "beagle";    
// use bracket notation for snoopy's age
var age = snoopy["age"];*/

I have a multi line comment to try what you suggested


#18

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