Looping through an object and changing all values

后端 未结 7 1637
庸人自扰
庸人自扰 2020-12-29 21:42

I\'m having trouble looping through an object and changing all the values to something else, let\'s say I want to change all the values to the string \"redacted\". I need to

7条回答
  •  滥情空心
    2020-12-29 22:33

    try

    var superSecret = function(spy){
      Object.keys(spy).forEach(function(key){ spy[key] = "redacted" });
      return spy;
    }
    

提交回复
热议问题