Use the delete Keyword to Remove Object Properties helpp

Use the delete Keyword to Remove Object Properties helpp
0

#1

i have passed this test using this code but is there a faster alternative?
i tried

delete foods['oranges','strawberries','plums']

but didnt work

Your code so far


let foods = {
  apples: 25,
  oranges: 32,
  plums: 28,
  bananas: 13,
  grapes: 35,
  strawberries: 27
};

// change code below this line
delete foods['oranges'];
delete foods['strawberries'];
delete foods['plums'];
// change code above this line

console.log(foods);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/use-the-delete-keyword-to-remove-object-properties


#2

delete is only going to delete one. The only other way I see would be to make a loop and delete that way if you were going to delete more than one. It would be more code, but it would be more practical than calling delete several times


split this topic #3

A post was split to a new topic: Need some help with delete Keyword to Remove Object Properties challenge