What is wrong i don't know


#1


Oops, try again. It looks like james' job was not logged to the console.


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"
james[aProperty];


#2

Hi,

the problem is in your last line "james[aProperty];". You need to use "console.log" to print it out.

That's how it looks: "console.log(james[aProperty]);"
Just change your last line from "james[aProperty];" to "console.log(james[aProperty]);"


#3

i did that bt it is still showing me error


#4

Here is the code for this task:

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]);

Hopefully this will help you! :slight_smile:


#5

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]);

Error: TypeError: console.log is not a function

Oops, try again. It looks like james' job was not logged to the console


#6

Strangely, I checked it on my own and it works, try to copy and paste the code (as a last resort)!

Compare with the task:

Take advantage of the ability to use variables with bracket notation.

In line 7, set aProperty to a string of the first property in james (ie. the job property).

Then print james's job using bracket notation and aProperty.


#7

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