Randell Dawson e9212c61d2 fix(curriculum): Remove unnecessary assert message argument from English challenges JavaScript Algorithms and Data Structures - 01 (#36401)
* fix: rm assert msg basic-javascript

* fix: removed more assert msg args

* fix: fixed verbiage

Co-Authored-By: Parth Parth <34807532+thecodingaviator@users.noreply.github.com>
2019-07-13 08:07:53 +01:00

1.7 KiB

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

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".

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.

Tests

tests:
  - text: Add the property <code>"bark"</code> to <code>myDog</code>.
    testString: assert(myDog.bark !== undefined);
  - text: Do not add <code>"bark"</code> to the setup section
    testString: assert(!/bark[^\n]:/.test(code));

Challenge Seed

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

ourDog.bark = "bow-wow";

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

// Only change code below this line.

After Test

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

Solution

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