1.7 KiB
1.7 KiB
id, title, challengeType, videoUrl, forumTopicId
id | title | challengeType | videoUrl | forumTopicId |
---|---|---|---|---|
56bbb991ad1ed5201cd392d3 | Delete Properties from a JavaScript Object | 1 | https://scrimba.com/c/cDqKdTv | 17560 |
Description
delete ourDog.bark;
Example:
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"],
"bark": "bow-wow"
};
delete ourDog.bark;
After the last line shown above, ourDog
looks like:
{
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
}
*/
Instructions
"tails"
property from myDog
. You may use either dot or bracket notation.
Tests
tests:
- text: You should delete the property <code>"tails"</code> from <code>myDog</code>.
testString: assert(typeof myDog === "object" && myDog.tails === undefined);
- text: You should not modify the <code>myDog</code> setup.
testString: 'assert(code.match(/"tails": 1/g).length > 0);'
Challenge Seed
// Setup
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"],
"bark": "woof"
};
// 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"],
"bark": "woof"
};
delete myDog.tails;