Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

673 B

title
title
Add Key-Value Pairs to JavaScript Objects

Add Key-Value Pairs to JavaScript Objects


Hints

Hint 1

  • The foods object has already been declared. All that is left to be done is to add three new key-values.
OBJECT[{ KEY }] = { VALUE };
  • The above code will create a ney key-value within the object.

Solutions

Solution 1 (Click to Show/Hide)
let foods = {
  apples: 25,
  oranges: 32,
  plums: 28
};
// change code below this line
foods["bananas"] = 13;
foods["grapes"] = 35;
foods["strawberries"] = 27;
// change code above this line
console.log(foods);