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

No problems with this one but… Wasn’t const a variable that could not be changed? That had the “read only” kind of property? I thought i was only able to edit this object with let or var but const also received the new entries.

Do i have the wrong idea about const?

Your code so far

const 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 OPR/102.0.0.0

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

Link to the challenge:

Double check what this Challenge said:

1 Like

It will work with objects only but never with values.

1 Like

Oh that’s perfect. Thank you for the reference and clarification!

1 Like