I want to update (replace) the objects in my array with the objects in another array. Each object has the same structure. e.g.
var origArr = [
const origArr = [
{name: 'Trump', isRunning: true},
{name: 'Cruz', isRunning: true},
{name: 'Kasich', isRunning: true}
];
const updatingArr = [
{name: 'Cruz', isRunning: false},
{name: 'Kasich', isRunning: false}
];
let hash = {};
for(let i of origArr.concat(updatingArr)) {
if(!hash[i]) {
hash[i.name] = i;
}
}
let newArr = [];
for(let i in hash) {
newArr.push(hash[i])
}
console.log(newArr);