--description--
We can also delete properties from objects like this:
delete ourDog.bark;
Example:
const 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--
Delete the tails
property from myDog
. You may use either dot or bracket notation.
--hints--
You should delete the property tails
from myDog
.
assert(typeof myDog === 'object' && myDog.tails === undefined);
You should not modify the myDog
setup.
assert(__helpers.removeJSComments(code).match(/"tails": 1/g).length > 0);
--seed--
--after-user-code--
(function(z){return z;})(myDog);
--seed-contents--
// Setup
const myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"],
"bark": "woof"
};
// Only change code below this line
--solutions--
const myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"],
"bark": "woof"
};
delete myDog.tails;