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.
Run code runs your code once for each case. It compares what your code prints with the expected output.
Starter code
or press Ctrl EnterNot run yet
cases
Not run yetIn order, then in reverse order
Expected output
1
one room: 12
two rooms: 23
two rooms: 24
one room: 1See 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());