Challenges • Asked almost 5 years ago by Anonymous
Hey David, one way around it is, you can define planeMatrix1 in your code, and copy over one of the example test until they fix the issue.
Link to problem: Count The Planes.
Yeah, looks like the runner is referencing a global planeMatrix1. Copying an example into your code will work, but a cleaner workaround is to make your solution pure and only adapt at the boundary:
// your actual solution
function countPlanes(matrix) {
// ... implement logic here
return 0;
}
// glue for the buggy runner
const mat =
(typeof globalThis !== 'undefined' && 'planeMatrix1' in globalThis)
? globalThis.planeMatrix1
: /* your local test data here */ [];
console.log(countPlanes(mat));
Key points:
- Don’t reference planeMatrix1 directly or in default params; accessing an undeclared identifier throws.
- Use globalThis lookup to avoid ReferenceError.
- Keep your logic testable by taking matrix as a parameter.
- Also worth reporting the challenge bug so they fix the harness.