Skip to content

Commit c757b24

Browse files
committed
updading code so tests are passed and result leads to unique common/shared item
1 parent ac594c9 commit c757b24

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Sprint-1/JavaScript/findCommonItems/findCommonItems.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@
1818

1919
export const findCommonItems = (firstArray, secondArray) => {
2020
const arrayToSet = new Set(secondArray);
21-
return firstArray.filter((element) => arrayToSet.has(element));
21+
for (const element of firstArray) {
22+
if (secondArray.includes(element)) {
23+
arrayToSet.add(element);
24+
}
25+
26+
}
27+
return arrayToSet;
2228
};

0 commit comments

Comments
 (0)