Answer to Question #219578 in Java | JSP | JSF for krish

Question #219578

Common Items in Three Arrays

Given three arrays

arr1, arr2 and arr3, write a JS program to find the common items among the three arrays.Input

  • The first line of input contains an array arr1
  • The second line of input contains an array arr2
  • The third line of input contains an array arr3

Output

  • The output should be a single line containing an array of common items among the three arrays

sample input 1

[1, 2, 3, 'cat']

[1, 'cat', 7, 10]

[1, 'cat', 16, 64]


sample output1

[ 1, 'cat' ]


1
Expert's answer
2021-07-22T06:48:43-0400
var arr= [1, 2, 3, 'cat']
var arr2=[1, 'cat', 7, 10]
var arr3  = [1, 'cat', 16, 64]
for (var i = 0; i < 4; i++) {
    if(arr[i]==arr2[i] and arr2[i]==arr3[i]){
        print(arr[i]);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS