Basic Data Structures - Add Key-Value Pairs to JavaScript Objects

What’s happening:
I have tried dot notation my answer being:
foods.bananas = ‘13’;
foods.grapes = ‘35’;
foods.strawberries = ‘27’;

As well as this i have tried multiple different ways including the hinted way and even that isn’t working leading me to believe I am doing something obviously wrong, please somebody point it out too me.

My code so far

let foods = {
  apples: 25,
  oranges: 32,
  plums: 28
};

// Only change code below this line
foods[bananas] = '13';
foods[grapes] = '35';
foods[strawberries] = '27';
// Only change code above this line

console.log(foods);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Challenge: Basic Data Structures - Add Key-Value Pairs to JavaScript Objects

Link to the challenge:

this is your code and the example you were probably basing this on is:
tekkenCharacter['hair color'] = 'dyed orange';

Do you notice any interesting use of punctuation that you did not use?
(and when should quotes be used anyway? do we need them for numbers?)

1 Like

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