I have tried this, but it is giving the correct result
Array1
Array1: [ { id: 2, city: 'washington', code: 0099, room: 5, ... }, { ... }, ... ] Array 2
Array2: [ { "id": 2, "name": "john" "number": 727625, "etage": 5, "status": 0, ... }, { ... }, ... ] My Code
let Result = []; if (Array1 && Array1.length > 0 && Array2 && Array2.length > 0) { Array1.forEach((arr1, index) => { Array2.forEach((arr2, index) =>{ if (arr1.id === arr2.id && arr1.room === arr2.etage) { Result.push(arr1) } }) }) } console.log(Result) What I want ?
I want items(objects) of Array1 by comparing both arrays, where both have same id's && room from Array1's object equal to the etage from Array2's object.
Please guide me, how can I do this in ES6 style in React js?