Assessment wanted for Events 01 skill test

const btnn = document.querySelector(’.off’);

// Add your code here
btnn.addEventListener(‘click’, (event) => {
console.log(event);
if(event.target.innerText === ‘Machine is off’) {
btnn.innerText = ‘Machine is on’;
} else {
btnn.innerText = ‘Machine is off’;
}
})

Hi @Sneha_Swara

Well done!

A small hint to make your code a bit more robust:
Texts tend to change over time in projects, therefore you could also base your condition on the class name (and also change it accordingly). This way you can change the button text later without touching the logic (the condition).
Something like this:

const btn = document.querySelector('.off');

btn.addEventListener('click', () => {
  if (btn.className === 'on') {
    btn.textContent = 'Machine is off';
    btn.className = "off";
  } else {
    btn.textContent = 'Machine is on';
    btn.className = "on";
  }
});

I hope that helps,
Michael