I am trying to convert the following code to something that uses the lodash _.filter
var substitutionValues = { one: "hi", two: undefined, three: 3};
var keys = _.keys(substitutionValues);
for (var i = 0; i < keys.length; i++) {
if (substitutionValues[keys[i]] === undefined) {
delete substitutionValues[keys[i]];
}
}
// => { one: "hi", three: 3 }
Please note I do not want to use lodash's _.reduce, _.pick, or _.omit.