Looping through an object and changing all values
try
var superSecret = function(spy){
Object.keys(spy).forEach(function(key){ spy[key] = "redacted" });
return spy;
}
You can also go functional.
Using Object.keys
is better as you will only go through the object properties and not it's prototype chain.
Object.keys(spy).reduce((acc, key) => {acc[key] = 'redacted'; return acc; }, {})