Oliver Eyton-Williams 0bd52f8bd1
Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
2020-11-27 10:02:05 -08:00

1.4 KiB

id, title, challengeType, videoUrl, forumTopicId
id title challengeType videoUrl forumTopicId
56bbb991ad1ed5201cd392d2 Add New Properties to a JavaScript Object 1 https://scrimba.com/c/cQe38UD 301169

--description--

You can add new properties to existing JavaScript objects the same way you would modify them.

Here's how we would add a "bark" property to ourDog:

ourDog.bark = "bow-wow";

or

ourDog["bark"] = "bow-wow";

Now when we evaluate ourDog.bark, we'll get his bark, "bow-wow".

Example:

var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]
};

ourDog.bark = "bow-wow";

--instructions--

Add a "bark" property to myDog and set it to a dog sound, such as "woof". You may use either dot or bracket notation.

--hints--

You should add the property "bark" to myDog.

assert(myDog.bark !== undefined);

You should not add "bark" to the setup section.

assert(!/bark[^\n]:/.test(code));

--seed--

--after-user-code--

(function(z){return z;})(myDog);

--seed-contents--

// Setup
var myDog = {
  "name": "Happy Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"]
};

// Only change code below this line

--solutions--

var myDog = {
  "name": "Happy Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"]
};
myDog.bark = "Woof Woof";