* fix: remove example code from challenge seed * fix: remove declaration from solution * fix: added sum variable back in * fix: reverted description back to original version * fix: added examples to description section * fix: added complete sentence Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: corrected typo Co-Authored-By: Manish Giri <manish.giri.me@gmail.com> * fix: reverted to original desc with formatted code * fix: removed unnecessary code example from description section Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * fix: failiing test on iterate through array with for loop * fix: changed to Only change this line Co-Authored-By: Manish Giri <manish.giri.me@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Manish Giri <manish.giri.me@gmail.com> Co-authored-by: moT01 <tmondloch01@gmail.com>
1.7 KiB
1.7 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
"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
"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: You should add the property <code>"bark"</code> to <code>myDog</code>.
testString: assert(myDog.bark !== undefined);
- text: You should not add <code>"bark"</code> to the setup section.
testString: assert(!/bark[^\n]:/.test(code));
Challenge Seed
// 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";