title: given a number N and 2 arrays A and B of sorted order of size N, print the common elements.If it is not found print -1
body: <p>please check my error in my code, my code get 2 array and then concat these two array, get this array to object and turn it to array again, sort it and return most common element.  </p>
  
  <pre><code>function plus() {
      let A = document.getElementById('array1').value;
      let B = document.getElementById('array2').value;
      let A1 = A.split(/\s+/g);
      let B1 = B.split(/\s+/g);
      let C = A1.concat(B1);
      let obj = {};
      for (let i=0; i&lt;C.length; i++) {
          if (obj[C[i].toString()] === undefined) {
              obj[C[i].toString()] = 1;
          }
          else {
              obj[C[i].toString()]++;
          }
      }
      let arr = [];
      for (let key in obj) {
          arr.push({
              number: key,
              repeat: obj[key]
          })
      }
      arr.sort(function (a,b) {
              return b.repeat - a.repeat;
          }
      );
      if (arr[0].repeat == arr[1].repeat) {
          console.log('-1');
      }
      else {
          console.log(arr[0].number);
  
      }
  
  
      }
  
  </code></pre>