Q:

Write a JavaScript program to check whether there is at least one element which occurs in two given sorted arrays of integers

0

 Write a JavaScript program to check whether there is at least one element which occurs in two given sorted arrays of integers.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function check_common_element(arra1, arra2) {
  for (var i = 0; i < arra1.length; i++)
  {
    if (arra2.indexOf(arra1[i]) != -1) 
      return true;
  }
  return false;
}
console.log(check_common_element([1,2,3], [3,4,5]));   
console.log(check_common_element([1,2,3], [5,6,7]));   

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now