Tell us what’s happening:
both answers are not working for this challenge, any help ?
this is the only problem :
The key-value pairs should be set using dot or bracket notation.
Your code so far
let foods = {
apples: 25,
oranges: 32,
plums: 28
};
// change code below this line
//my answer 1
foods = {...foods, bananas:13, grapes: 35, strawberries:27};
//my answer 2
foods.bananas = 13;
foods.grapes = 35;
foods.strawberries =27;
//after viewing the website answer
foods["bananas"] = 13;
foods["grapes"] = 35;
foods["strawberries"] = 27;
// change code above this line
console.log(foods);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36
.
Challenge: Add Key-Value Pairs to JavaScript Objects
Link to the challenge: