title: Merge two arrays without PreDefined functions In javascript
body: <p>I was trying to merge two arrays in Js. I have done this by learning a logic but getting an issue. I am getting undefined values at few indexes of new array.</p>
  
  <pre><code>  const arr3 = [];
    const length1= arr1.length;
    const length2 = arr2.length;
    let k = 0;
    const totalLength = length1 + length2;
    for(let i=0 ; i&lt;=totalLength; i++){
        arr3.push(arr1[i]);
         if(i &gt; length1){
          arr3.push(arr2[k]);
           k= k+1;
           }
    }
    return arr3;
  }
  
  merge([1,3,25,5], [5,4,9,7]); ```
  
  i am getting an output
  
  </code></pre>
  
  <p>[1,3,25,5, undefined, undefined,5, undefined, 4 ,undefined, 9, undefined, 7]</p>
  
  <pre><code>
  </code></pre>