---
id: 6989f555728e63ad8b349d84
title: Step 10
challengeType: 1
dashedName: step-10
---

# --description--

If the current string isn't complete yet, you need to explore the next possible states. Add an `else` clause for the current `if` statement.

Inside the `else` block, you'll handle adding opening parentheses. Add an `if` statement to check if `opensUsed` is less than `pairs`. This ensures you don't use more opening parentheses than allowed.

If this condition is `true`, push a new array to the `queue`: `[current + '(', opensUsed + 1, closesUsed]`. This represents the state after adding an opening parenthesis.

# --hints--

You should have an `else` clause for your `if` statement inside the `while` loop.

```js
assert.match(genParentheses.toString(), /if\s*\(\s*current\.length\s*===?\s*2\s*\*\s*pairs\s*\)\s*\{[\s\S]*?\}\s*else\s*\{/);
```

You should have an `if` statement inside the `else` block with the condition `opensUsed < pairs`.

```js
assert.match(genParentheses.toString(), /else\s*\{[\s\S]*?if\s*\(\s*opensUsed\s*<\s*pairs\s*\)/);
```

You should push `[current + '(', opensUsed + 1, closesUsed]` to the queue when the condition is `true`.

```js
assert.match(genParentheses.toString(), /queue\.push\s*\(\s*\[\s*current\s*\+\s*['"`]\(['"`]/);
```

# --seed--

## --seed-contents--

```js
function genParentheses(pairs) {
  if (!Number.isInteger(pairs)) {
    return 'The number of pairs should be an integer';
  }
  if (pairs < 1) {
    return 'The number of pairs should be at least 1';
  }

  let queue = [['', 0, 0]];
  let result = [];

  while (queue.length > 0) {
    console.log(queue);
    let [current, opensUsed, closesUsed] = queue.shift();
    if (current.length === 2 * pairs) {
      result.push(current);
--fcc-editable-region--
    } 
--fcc-editable-region--
  }
  return result;
}

console.log(genParentheses(1));
```
