Stop blinking in Lite Brite project using clearInterval


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript/projects/lite-brite

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I am trying to make the blinking stop when clicking again the BLINK button, but checking for the class in the BLINK button does not seem to work.

```

$(’.toggle-blink’).on(‘click’, function(){
var interval
if (colorClass){
$(this).toggleClass(‘opacity’);
interval= setInterval(function() {
$(’.box.cyan, .box.yellow, .box.magenta’).toggleClass(‘blink’);
}, 350);
if ($(this).hasClass(‘opacity’)) {
clearInterval(interval)
}
}
})

<do not remove the three backticks above>

#2

This topic was automatically closed after 7 days. New replies are no longer allowed.