Skip to content

Commit f86a30f

Browse files
authored
Update js codes.docx
1 parent c917ff4 commit f86a30f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎js codes.docx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,13 @@ console.log(updatedArr)//{0: 'John', 1: 'Peter', 2: 'Sally', 3: 'Jane'}
15301530
2. Used to modify an element in array depending on some requirement, which means calling a function on each item in Array
15311531
3. Used to convert String to Array
15321532
================================================================================================================================================================================
1533-
1533+
103. Find common elements:
1534+
function commonElements(a, b){
1535+
return a.filter((item) => b.includes(item))
1536+
}
1537+
A = [1.2,3,4,5];
1538+
B = [4, 5, 6, 7, 8];
1539+
console.log(commonElements(A, B)); //[4,5]
15341540
================================================================================================================================================================================
15351541

15361542
================================================================================================================================================================================

0 commit comments

Comments
 (0)