Each test gets its own list

Each test needs its own starting data.

your task

Start each test with an empty selection. Keep both tests and their print lines. Each test must count only its own rooms in either order.

The second test selects two rooms but counts three. Its list still contains the first test’s room. The runner then repeats the tests in reverse order.

Starter code
or press Ctrl EnterNot run yet

cases

Not run yetIn order, then in reverse order

Expected output

1one room: 1
2two rooms: 2
3two rooms: 2
4one room: 1
See the input and the code for this case
const tests = [];
const hooks = [];
function test(name, body) {
  tests.push(body);
}
function beforeEach(hook) {
  hooks.push(hook);
}
function runAll(list) {
  for (const body of list) {
    for (const hook of hooks) hook();
    body();
  }
}
runAll(tests);
runAll([...tests].reverse());