diff --git a/index.js b/index.js index e181a66..0ede79e 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,15 @@ // part 1 stopButton.addEventListener('click', () => { stopLight.classList.toggle('stop'); + + // or... + // if (stopLight.classList.contains('stop')) { + // stopLight.classList.remove('stop'); + // } + // else { + // stopLight.classList.add('stop'); + // } + }); slowButton.addEventListener('click', () => { @@ -51,6 +60,14 @@ if (event.target === stopButton) { status = stopLight.classList.contains('stop') ? 'on' : 'off'; + + // or... + // if (stopLight.classList.contains('stop')) { + // status = 'on'; + // } + // else { + // status = 'off'; + // } } else if (event.target === slowButton) { status = slowLight.classList.contains('slow') ? 'on' : 'off';