Bracket Notation with Objects Issue


Hello,

Can anyone tell me what I am doing wrong here for this tutorial? I try to input a str here into the square brackets, but I get an error saying that I can’t insert a string there.

Is there another way to put a string here to set the object property?

Thank you.

Hey, Try to add property, rather than adding the property directly to animal
and,
‘Age’ in the Bracket
For Example
animal [‘age’] = 5.

Thanks for the response. That is what I am trying to do, but the app is not allowing me to type in ‘age’ into the brackets.

1 Like

Hey there, add a new line after the object and use bracket notation there, like this:

let animal = {
name: ‘Pooch’,
species: ‘Dog’
}
animal[‘age’] = 12