jeudi 11 octobre 2018

Is it possible to modify the value of one array while searching through another in Javascript and Vue?

If I have two arrays that both contain objects. Is it possible to modify the item value of one array while looping through another if certain items match? Such as a name?

Currently, I'm looping though the first array, displaying the names, with checkboxes (all checked) beside them. If I uncheck the checkbox, set both arrays where the name is the same, to visible: false

I'm also using Vue, if that makes things any easier

Say;

array 1 = [{Name: John, Age: 19, Visible: false}, {Name: Frank, Age: 20, Visible: true}, {Name: Kate, Age: 20, Visible: true}]

array 2 = [{Name: John, Age: 30, Visible: true}, {Name: William, Age: 20, Visible: true}, {Name: Henry, Age: 40, Visible: true}]

Is it possible to set it where if two names match, set both to visible false. In this example, it would be "John". So "John" in the first array is visible: true, so I'd like both to be visible: false




Aucun commentaire:

Enregistrer un commentaire