what do you think is the best way to do ?
Reduce Way :
const result = Object.keys(params).reduce(
(previous, key) => {
if (this.model.hasOwnProperty(key)) previous[key] = this.model[key](params[key]);
return previous;
}, {});
ForEach Way:
const result = {};
Object.keys(params).forEach(key => {
if (this.model.hasOwnProperty(key)) result[key] = this.model[key](params[key]);
});
I'm using airbnb eslint and it doesn't like the reduce way since I modify previous
(no-param-reassign)