Open VivaTychina opened 1 year ago
✅
function getCommonElements(firstArray, secondArray) { const commonElements = []; // Change code below this line
for (let i = 0; i < firstArray.length; i += 1) { if (secondArray.includes(firstArray[i])) { commonElements.push(firstArray[i]); } }
return commonElements; // Change code above this line }
function getCommonElements(firstArray, secondArray) { const commonElements = [];
firstArray.forEach(element => { if (secondArray.includes(element)) { commonElements.push(element); } }); return commonElements;
}
✅
function getCommonElements(firstArray, secondArray) { const commonElements = []; // Change code below this line
for (let i = 0; i < firstArray.length; i += 1) { if (secondArray.includes(firstArray[i])) { commonElements.push(firstArray[i]); } }
return commonElements; // Change code above this line }
✅
function getCommonElements(firstArray, secondArray) { const commonElements = [];
}