Robot name exercise doesn't execute the tests

The Robot name exercise in JavaScript gets the error: An error occurred

We received the following error when we ran your code:

Identifier 'beforeEach' has already been declared
```                          Here is my code: const LENGTH_OF_ALPHABET = 26;
const FIRST_ASCII = 'A'.charCodeAt(0);

/**
 * The strategy here is to generate every possible name once, then randomly shuffle them. If we were to
 * randomly generate a name each time, it becomes increasingly unlikely that we'll generate a unique
 * name. By creating an array of all possibilities that have been shuffled, we ensure we get an unused
 * name by popping from that list every time we need a new one.
 */
const generateAlphaCombos = (length, combo = '') => length
  ? [...Array(LENGTH_OF_ALPHABET).keys()]
    .flatMap(i => generateAlphaCombos(length - 1, combo + String.fromCharCode(i + FIRST_ASCII)))
  : combo;

const generateNumericalCombos = length => [...Array(10 ** length).keys()].map(num => `${num}`.padStart(length, '0'));

const generatePossibleNames = (alphaLength, numLength) => generateAlphaCombos(alphaLength)
  .flatMap(alphaCombo => generateNumericalCombos(numLength).map(numCombo => alphaCombo + numCombo));

// Randomly shuffle list of all possible names using Fisher-Yates
const shuffleNames = ([...names]) => names.reduce((shuffled, _, first) => {
  const second = Math.floor(Math.random() * first);
  [shuffled[first], shuffled[second]] = [shuffled[second], shuffled[first]];
  return shuffled;
}, names);

export class Robot {
  static ALPHABETICALS_LENGTH = 2;
  static NUMERICALS_LENGTH = 3;
  static POSSIBLE_NAMES = generatePossibleNames(Robot.ALPHABETICALS_LENGTH, Robot.NUMERICALS_LENGTH);
  static ELIGIBLE_NAMES = shuffleNames(Robot.POSSIBLE_NAMES);

  static releaseNames() {
    Robot.ELIGIBLE_NAMES = shuffleNames(Robot.POSSIBLE_NAMES);
  }

  #name

  constructor() {
    this.reset();
  }

  get name() {
    return this.#name;
  }

  reset() {
    this.#name = Robot.ELIGIBLE_NAMES.pop();
  }
}

There was a fix for this issue back in Oct 2025. Is your version of the Exercise up-to-date? When you visit the exercise page, do you see a banner on top asking about an update?

No, I can’t see any update. How can I submit my solution?

@Cool-Katt @SleeplessByte Can you help here?

1 Like

I’m assuming that you’re working through the web editor, in which case the error is likely not from your end, so fear not (well, maybe just a little…)

To address the question directly, you can try to test and submit your solution through the CLI tool.


In the meantime, @SleeplessByte I can reproduce the error on my end in the web editor, so I’m assuming the test runner is misconfigured somehow again, probably related to this? and the PR in question?

1 Like

Yesss.

I have to apologize: totally forgot about it. Busy busy live on wheels.

I’ll attempt to prioritize this!

The import issue that was present in the past has been resolved

1 Like