Why its giving me this error # Fatal error in , line 0 # Fatal JavaScript invalid size error 169220804?

The code consist of making an array from a range of number 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 step with a negative number as an argument Ex. NumberRange(10,5,-2); Thats when the error appears, in the code it shows the logic I used for a negative step.
Image of the error

”’

function NumberRange(start, end, step){
            
            var numberList = [];

            if(typeof(step) == 'undefined'){
                
                if(start < end){
                    for(;start <= end; start++){
                        numberList.push(start);
                    }

                    console.log(numberList);
                }
                else if(start > end){
                    for(;start >= end;){
                        numberList.push(start);
                        start -= 1;
                    }
                    
                    console.log(numberList);
                }
            }
            else if(start > end && (Math.sign(step) == -1)){  // This is the logic I created when a negative step is given as an argument.
                for(;start >= end; start - step){
                    numberList.push(start);
                }

                console.log(numberList);
            }
            else if(start < end && (Math.sign(step) == -1)){
                console.log("Negative step cant work since the value of the beginning of the list is less than the end of it")
            }
            else{
                for(;start <= end;){
                    numberList.push(start);
                    start += step;
                }

                console.log(numberList);
            }

            //return numberList;
        };

        NumberRange(10,5,-2);

”’