The code only returns an error in CodeCademy. Can't find the problem

In lesson 5/30 in Introductory Objects 2 for CodeCademy, they want you to use encoding. if i run this code on jsfiddle it outputs "programmer" to the console, but in codecademy it gives the error "Oops, please try again. It looks like work on james has not been registered in the console". Any suggestions?

var james = {
    job: "programmer",
    married: false
};

// set to the first property name of "james"
var aProperty = "job";

// print the value of the first property of "james" 
// using the variable "aProperty"

console.log(james[aProperty]);

      

+3


source to share


3 answers


I had problems with this too. Instead of using:

var aProperty = james["job"];
console.log(aProperty);

      



Try:

var aProperty = ["job"];
console.log(aProperty);

      

0


source


I had the same problem. If anyone stumbles over this, try changing your browser.

I had to switch from Chrome to IE for the code to work.



The code Austin provided is correct.

0


source


I suppose you should assign the variable 'aProperty' with a bracket notation.

try:

var aProperty = james["job"];
console.log(aProperty);

      

-1


source







All Articles