mutating function side affects

PHOTO EMBED

Tue Feb 09 2021 06:46:30 GMT+0000 (UTC)

Saved by @noobj

const foo = {
  'ONE':1,
  'TWO':2
};

const mapMultiplier = (params, multiplier) => {
  params.ONE = params.ONE * multiplier
  params.TWO = params.TWO * multiplier
  return params;
};

console.log(mapMultiplier(foo, 2));
console.log(mapMultiplier(foo, 3));
console.log(mapMultiplier(foo, 4));

// Value of foo { 'ONE': 1, 'TWO': 2 }
console.log('foo: ', foo);
content_copyCOPY