Unexpectedly, here is a JS error I found on developer.mozilla.org

| Programming | 2nd May 2025

Share on:

I was looking over the documentation for JS events and because the time permits I clicked on “Test your skills: Events” link from the JS Events page to see what it is about.

The Events 1 section has a small test where you are asked to create an event handler that will change the text on a button back and forward from “Machine is off” to “Machine is on”.

I wrote the next code to solve the problem


const btn = document.querySelector('.off');
const offText = 'Machine is off';
const onText = 'Machine is on';
console.log('*********', btn.innerText);

function changeText() {
btn.innerText = (btn.innerText === onText) ? offText : onText;
}
btn.addEventListener('click', changeText);

The above code suppose to make the button from the bellow image to change its text when clicked, but it was not happening.

So I started to investigate by looking at the DevTools in the Console tab and I found that https://developer.mozilla.org is not actually parsing the right code when is executed.

Here is an error found there “Uncaught ReferenceError: bt is not defined” and clicking on the source file linked at the right I found

It was obvious enough that this apprication didn’t get enough testing and it went live with bugs.