Answers for "how to push mutual array elements in an array nested loop javascript"

0

how to push mutual array elements in an array nested loop javascript

let array1 = ['element1', 'element2', 'element3', 'element4'];
let array2 = ['array2element', 'element2', 'element4'];
let mutualArrayElements = [];

for (let i = 0; i < array1.length; i++) {
  for (let j = 0; j < array2.length; j++) {
    if (array1[i] === array2[j]) {
      mutualArrayElements.push(array1[i]);
    }
  }
};
// for nested loops
Posted by: Guest on November-19-2020

Code answers related to "how to push mutual array elements in an array nested loop javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language