Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Cancelling a timeout

Hi,

Under 'Cancelling a Timeout' in the teachers notes, should the 'intervalID' variable not be calling the setInterval function rather than 'clearInterval?.

2 Answers

Steven Parker
Steven Parker
243,266 Points

The "setInterval" function creates a timer, and returns an ID.

The "clearInterval" function cancels and interval, and you pass it the ID.

If you have a question about something on a particular course page, please include a link to the page.

Apologies Steven, I though it would link when I asked the question. I mean here:

https://teamtreehouse.com/library/using-a-repeat-timer-with-setinterval

Under 'Cancelling a Timeout' in the teachers notes, the initial function is declared as a 'clearInterval', not a 'setInterval'.

Steven Parker
Steven Parker
243,266 Points

Good eye! You should submit this as a bug to the Support folks.

You will probably get an "Extermintor" :beetle: badge for it!