Use Dot Notation to Access the Properties of an Object

Tell us what’s happening:
Created a small for loop to print out the property values of the object.
It is not accepting this method as a valid answer.
Did I do it wrong or can this be implemented as an answer?

Your code so far


let dog = {
  name: "Spot",
  numLegs: 4
};
// Add your code below this line
for (var x in dog){
    console.log(dog[x])
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming/use-dot-notation-to-access-the-properties-of-an-object/

The challenge nae is “use dot notation to access the properties of an object”, but you didn’t use dot notation.

2 Likes

Thx :slight_smile: I was wondering why it wouldn’t accept my answer

};
// Add your code below this line
for (var x in dog){
console.log([x])
}

You need to use dot notation to pass the challenge, that is not dot notation