title: Flatten array using recursion
body: <p>I have to flatten an array using recursion, but I am not able to understand, why this code is always outputting an empty array. Can someone please help me here.
  This is the code</p>
  <pre><code>function flatten(arr){
      let result = [];
      function helper(arr) {
          
          for(let i = 0; i&lt;arr.length; i++){
              if(Array.isArray(arr[i])){
                  helper(arr[i]);
                  return result;
              }else{
                  result.push(arr[i]);
              }
          }
      }
      return result;
  }
  </code></pre>