Improve the solution
This commit is contained in:
parent
0336132c61
commit
43488eeaea
17
index.js
17
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';
|
||||
|
Loading…
x
Reference in New Issue
Block a user