I am building a card game app in React and am trying to filter if one array that has multiple 'cards' has a value of 6 in the present array. For example:
let arr = [{type: "span", key: "51", ref: null, props: {children: "6"}}, { type: "span", key: "52", ref: null, props: {children: "7"}}, { type: "span", key: "53", ref: null, props: {children: "6"}}]
let arr2 = [{ type: "span", key: "50", ref: null, props: {children: "6"}}]
let result = arr.filter((card) => {
return arr2 === card
})
console.log(result) //returns []
//I want it to return the items that have props:{children: "6"}
And then I need to remove the item from arr and place it in arr2. Then i would do something like this?
this.setState(({arr2, arr}) => {
return {
arr2: [...arr2, ...arr.slice(0, 1)],
arr: [...arr.slice(1, arr.length)]
};
});
arr2 === cardwill never be true. TwoArrayinstances are always distinct.