title: What is faster - merge 2 sorted arrays into a sorted array w/o duplicate values
body: <p>I was trying to figure out which is the fastest way to do the following task:</p>
  
  <p>Write a function that accepts two arrays as arguments - each of which is a sorted, strictly ascending array of integers, and returns a new strictly ascending array of integers which contains all values from both of the input arrays.</p>
  
  <p>Eg. merging [1, 2, 3, 5, 7] and [1, 4, 6, 7, 8] should return [1, 2, 3, 4, 5, 6, 7, 8].</p>
  
  <p>Since I don't have formal programming education, I fint algorithms and complexity a bit alien :) I've came with 2 solutions, but I'm not sure which one is faster.</p>
  
  <p>solution 1 (it actually uses the first array instead of making a new one):</p>
  
  <pre><code>function mergeSortedArrays(a, b) {
    for (let i = 0, bLen = b.length; i &lt; bLen; i++) {
      if (!a.includes(b[i])) {
        a.push(b[i])
      } 
    }
    console.log(a.sort());
  }
  
  const foo = [1, 2, 3, 5, 7],
        bar = [1, 4, 6, 7, 8];
  mergeSortedArrays(foo, bar);
  </code></pre>
  
  <p>and solution 2:</p>
  
  <pre><code>function mergeSortedArrays(a, b) {
    let mergedAndSorted = [];
  
    while(a.length || b.length) {
      if (typeof a[0] === 'undefined') {
        mergedAndSorted.push(b[0]);
        b.splice(0,1);
      } else if (a[0] &gt; b[0]) {
        mergedAndSorted.push(b[0]);
        b.splice(0,1);
      } else if (a[0] &lt; b[0]) {
        mergedAndSorted.push(a[0]);
        a.splice(0,1);
      } else {
        mergedAndSorted.push(a[0]);
        a.splice(0,1);
        b.splice(0,1);
      }
    }
    console.log(mergedAndSorted);
  }
  
  const foo = [1, 2, 3, 5, 7],
        bar = [1, 4, 6, 7, 8];
  mergeSortedArrays(foo, bar);
  </code></pre>
  
  <p>Can someone help me with time complexity of both solutions? Also, is there another, faster solution? Should I be using reduce()?</p>