Fizz Buzz function that returns an array I am a newbie to JS and I am working on a FizzBuzz challenge. Below is what I have tried. Essentially when the function takes a value then it would iterate from 1 up to the value and an array would result.
I am seeking advice on adding conditional checking such as:

If the value of n is less than 4, it will return the string: &quot;Please insert a value greater than or equal to 4&quot;.
If the function is passed no value, it should return an empty array.

I am not sure where to add and should I be using if...else or simply if for each conditional checking.
var fizzBuzz = function(n, arr = []) {   
  for (let i = 1; i &lt; n; i++) {
  if (n === 1) {                         
    arr.push('1');
    return arr.reverse();
  } else {                               
    if (n % 4 === 0 &amp;&amp; n % 5 === 0) {
      arr.push('FIZZBUZZ');
    } else if (n % 5 === 0) {
      arr.push('Buzz');
    } else if (n % 4 === 0) {
      arr.push('Fizz');
    } else {
      arr.push('' + n);
    }
    return fizzBuzz(n - 1, arr);         
  }
  }
}
I am hoping to seek advice on adding conditional checking such as: 1) if the value n is less than 4, it will return the string: &quot;Please insert a value greater than or equal to 4&quot; and 2) if the function is passed no value, it should return an empty array. I am not sure where to add and should I be using if...else or simply if for each conditional checking.

If we check for n &lt; 4 and returns a fixed string &quot;Please insert a value greater than or equal to 4&quot; anyway, do we really need to do anything before it? If we don't need to do anything before it, where should we put it?
Same goes for 2) if the function is passed no value, it should return an empty array

For the code itself, some points
1. Let's look at the loop
for (let i = 1; i &lt; n; i++) {
  if (n === 1) {                         
    // blah
    return arr.reverse();
  } else {                               
    // blah
    return fizzBuzz(n - 1, arr);         
  }
}

On every iteration this will return something. The for loop won't even need to go through the next iteration, it will always break and return on any iteration(!). You are doing recursion and loop at the same time.
2. arr.push('' + n);
Maybe use toString() method for numbers arr.push(n.toString());
3. if-else and returns
if (n === 1) {                         
    arr.push('1');
    return arr.reverse();
} else {   
    // blah    
}

Since the if block will always return, we don't need the else. This can be rewritten as
if (n === 1) {                         
    arr.push('1');
    return arr.reverse();
}
  
// the else blah    
```