---
id: 69b58ce40693f140c84c855a
title: "Challenge 241: FizzBuzz Validator"
challengeType: 28
dashedName: challenge-241
---

# --description--

Given an array of sequential integers, with multiples of 3 and 5 replaced, determine if it's a valid FizzBuzz sequence.

In a valid FizzBuzz sequence:

- Multiples of 3 are replaced with "Fizz".
- Multiples of 5 are replaced with "Buzz".
- Multiples of both 3 and 5 are replaced with "FizzBuzz".
- All other numbers remain as integers.

# --hints--

`isFizzBuzz([1, 2, "Fizz", 4, "Buzz"])` should return `true`.

```js
assert.isTrue(isFizzBuzz([1, 2, "Fizz", 4, "Buzz"]));
```

`isFizzBuzz([13, 14, "FizzBuzz", 16, 17])` should return `true`.

```js
assert.isTrue(isFizzBuzz([13, 14, "FizzBuzz", 16, 17]));
```

`isFizzBuzz([1, 2, "Fizz", 4, 5])` should return `false`.

```js
assert.isFalse(isFizzBuzz([1, 2, "Fizz", 4, 5]));
```

`isFizzBuzz(["FizzBuzz", 16, 17, "Fizz", 19, "Buzz"])` should return `true`.

```js
assert.isTrue(isFizzBuzz(["FizzBuzz", 16, 17, "Fizz", 19, "Buzz"]));
```

`isFizzBuzz([1, 2, "Fizz", "Buzz", 5])` should return `false`.

```js
assert.isFalse(isFizzBuzz([1, 2, "Fizz", "Buzz", 5]));
```

`isFizzBuzz([97, 98, "Buzz", "Fizz", 101, "Fizz", 103])` should return `false`.

```js
assert.isFalse(isFizzBuzz([97, 98, "Buzz", "Fizz", 101, "Fizz", 103]));
```

`isFizzBuzz(["Fizz", "Buzz", 101, "Fizz", 103, 104, "FizzBuzz"])` should return `true`.

```js
assert.isTrue(isFizzBuzz(["Fizz", "Buzz", 101, "Fizz", 103, 104, "FizzBuzz"]));
```

# --seed--

## --seed-contents--

```js
function isFizzBuzz(arr) {

  return arr;
}
```

# --solutions--

```js
function isFizzBuzz(arr) {
  let start = null;
  for (let i = 0; i < arr.length; i++) {
    if (typeof arr[i] === "number") {
      start = arr[i] - i;
      break;
    }
  }

  if (start === null) return false;

  for (let i = 0; i < arr.length; i++) {
    const n = start + i;
    const expected = n % 15 === 0 ? "FizzBuzz" : n % 3 === 0 ? "Fizz" : n % 5 === 0 ? "Buzz" : n;
    if (arr[i] !== expected) return false;
  }

  return true;
}
```
