Reputation: 125
I'm creating a rewards site where people can watch videos to earn points. The problem is that people will skip to the end of the video to earn their points. Therefore, I need to track when the video is done by a timer.
I have the following code:
var video_percent_count = 0;
function video_percent() {
var prize_video = document.getElementById("prize_video");
total_duration = Math.floor(prize_video.duration) + 1;
video_percent_count++;
percent = =total_duration / video_percent_count;
alert(percent);
}
To summarize, the code is adding to a variable every second, this is the timer. The function then grabs the total duration, then divides it by the timer for a percentage.
The function is not outputting a proper percentage, why is this code incorrect?
Upvotes: 0
Views: 87
Reputation: 4555
You've got a syntax error:
percent = =total_duration / video_percent_count;
Should be:
percent = total_duration / video_percent_count;
Notice the second =
is removed.
In the future, you can use the web console to find simple syntax errors such as this one.
Upvotes: 1