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


Imagine you work at a video streaming service. You want to keep track of where a user was on a video so if they navigate

In the quiz of callback, there was this question as stated,

Q: Imagine you work at a video streaming service. You want to keep track of where a user was on a video so if they navigated away they could come back and resume where they left off. Which function would you use?

but I couldn't understand how can we track when someone navigate away and come back to play video?

2 Answers

Steven Parker
Steven Parker
229,608 Points

You didn't mention which course, or provide a link to the quiz. So I'm not sure if the relates to the answer, but one way to accomplish this would be with the browser's local storage feature.

There's a workshop available here on Using Local Storage with JavaScript.

Steven Parker
Steven Parker
229,608 Points

Prompted by L Haney's recent post, I revisited this old question and found the reference in this quiz.

I think I finally understand the confusion — but the quiz question is only asking which timing function you might use to update a tracking point every second. The local storage would come into play as a way to store the position, and when the user returned to the page to pick up the last saved position for continuing.

So ammarkhan did your original question get answered? You can mark a question solved by choosing a "best answer".
And happy coding!

This is from the "Callback Functions in JavaScript" course.

I was confused by this question too, there's no way to know whether you need to use setInterval or setTimeout, based on the information provided. It's too vague.

Hint: The question does want to be able to track a user's playback at a regular interval, not just once.