Common Items in Three Arrays
Given three arrays
sample input 1
[1, 2, 3, 'cat']
[1, 'cat', 7, 10]
[1, 'cat', 16, 64]
sample output1
[ 1, 'cat' ]
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]);
}
}
Comments
Leave a comment