foods
object example one last time. If we wanted to remove the apples
key, we can remove it by using the delete
keyword like this:
delete foods.apples;
oranges
, plums
, and strawberries
keys from the foods
object.
foods
object only has three keys: apples
, grapes
, and bananas
'
testString: 'assert(!foods.hasOwnProperty("oranges") && !foods.hasOwnProperty("plums") && !foods.hasOwnProperty("strawberries") && Object.keys(foods).length === 3, "The foods
object only has three keys: apples
, grapes
, and bananas
");'
- text: 'The oranges
, plums
, and strawberries
keys are removed using delete
'
testString: 'assert(code.search(/oranges:/) !== -1 && code.search(/plums:/) !== -1 && code.search(/strawberries:/) !== -1, "The oranges
, plums
, and strawberries
keys are removed using delete
");'
```