Javascript logo

Obviously, it's a often cased task to update an object, or even a property in one object the array of objects. Especially it's actual for React applications.

You can use spread to make a copy and then to update previous value. But why to make garbage in memory?

The best solution is with map

        const newMatches = matches.map( (x, ind) => {
            return (ind === index) ? { ...x, avG: parseInt(e.target.value, 0) } : x
        })

Have questions? write down in the comments