Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const compareArrs = (arr1, arr2) => {
- const rtnArr = []
- for (let ar1 of arr1){
- for (let ar2 of arr2){
- if (JSON.stringify(ar1) === JSON.stringify(ar2)){
- rtnArr.push(ar1)
- }
- }
- }
- return rtnArr
- }
- // compare [1, 2] [3, 4] with [1, 2]
- console.log(compareArrs([[1, 2], [3, 4]], [[1, 2]]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement