let A= [1,2,3,5,8,7,6,5,9,1,1,6,9,8]; let B= [5,8,7]; let a= A.toString(); let b= B.toString(); console.log(a) console.log(b) if(a.indexOf(b) != -1){ console.log(A.indexOf(B[0])) }else{ console.log(-1) }