Skip to content

Instantly share code, notes, and snippets.

@alx8437
Created July 30, 2020 14:32
Show Gist options
  • Save alx8437/a2ec155989529d0e50374434cf6dcce7 to your computer and use it in GitHub Desktop.
Save alx8437/a2ec155989529d0e50374434cf6dcce7 to your computer and use it in GitHub Desktop.
let arr1 = [
{id: "pduutGbL2-M", isChecked: true},
{id: "J6MJPuJiDPo", isChecked: true}
]
let arr2 = [
{id: "pduutGbL2-M", isChecked: false},
{id: "J6MJPuJiDPo", isChecked: false},
{id: "WD6jyaFrVM8", isChecked: false},
{id: "ULP07chR5EQ", isChecked: false}
]
for(const el of arr1) {
const index = arr2.findIndex(x => x.id === el.id);
arr2[index].isChecked = true;
}
console.log(arr2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment