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 be able to do this in pure JavaScript.
For example I'd have an object like this...
spy = {
id: 007,
name: "James Bond",
age: 31
};
and the object would look like this after...
spy = {
id: "redacted",
name: "redacted",
age: "redacted"
};
Here is what I have to start with
var superSecret = function(spy){
// Code Here
}
This shouldn't create a new spy object but update it.
Object.keys(spy)to get the property names, then loop over that using say forEach. Lots of questions and answers here on that.