Why does a js map on an array modify the original array?
You’re not modifying your original array. You’re modifying the objects in the array. If you want to avoid mutating the objects in your array, you can use Object.assign to create a new object with the original’s properties plus any changes you need: const freeProduct = function(products) { return products.map(x => { return Object.assign({}, x, { … Read more