title: Why its giving me this error # Fatal error in , line 0 # Fatal JavaScript invalid size error 169220804?
body: <p>The code consists of making an array from a range of numbers and as well having a third argument in which it indicates the steps from the numbers, if it has a step of 2 well for example it goes from [1,3,5] the code works fine except when I pass <code>step</code> with a negative number as an argument e.g. <code>NumberRange(10,5,-2)</code>; That's when the error appears, in the code it shows the logic I used for a negative step.</p>
  <p><a href="https://i.stack.imgur.com/HMPGO.png" rel="nofollow noreferrer">Image of the error</a></p>
  <pre><code>function NumberRange(start, end, step){
              
      var numberList = [];
  
      if(typeof(step) == 'undefined'){
          
          if(start &lt; end){
              for(;start &lt;= end; start++){
                  numberList.push(start);
              }
  
              console.log(numberList);
          }
          else if(start &gt; end){
              for(;start &gt;= end;){
                  numberList.push(start);
                  start -= 1;
              }
              
              console.log(numberList);
          }
      }
      else if(start &gt; end &amp;&amp; (Math.sign(step) == -1)){  // This is the logic I created when a negative step is given as an argument.
          for(;start &gt;= end; start - step){
              numberList.push(start);
          }
  
          console.log(numberList);
      }
      else if(start &lt; end &amp;&amp; (Math.sign(step) == -1)){
          console.log(&quot;Negative step cant work since the value of the beginning of the list is less than the end of it&quot;)
      }
      else{
          for(;start &lt;= end;){
              numberList.push(start);
              start += step;
          }
  
          console.log(numberList);
      }
  
      //return numberList;
  };
  
  NumberRange(10,5,-2);
  </code></pre>