Here is my code, I would like some help please to find out why is it not working.
The course I am takeing is not up to date and probablly as the languages have evolve there are some errors along the way.
I want to find out if this is true and how can I keep up too date .
Thank you!
This is the code bellow :
// If we click on the start /reset button
// If we are playing
// Reload page
// If we are not playing
// Set score to 0
// show countdown box
// reduce the time by 1 second in loops
// time left?
// YES -> Continue
// NO <- Game Over!
// Change button to reset
// Generate Q & As
// If we click on an answer box
// If we are playing
// Correct?
// Yes
// Increase score
// Show Correct box for 1 second
// Generate new Q & As
// No
// Show Try Again box for 1 second
function () {
"use strict";
}
var playing = false;
var score;
var action;
var timeremaining;
document.getElementById("startreset").onclick = function () {
if (playing === true) {
location.reload();
} else {
playing = true;
score = 0;
document.getElementById("scorevalue").innerHTML = score;
show("timeremaining");
timeremaining = 60;
document.getElementById("timeremainingvalue").innerHTML = timeremaining;
hide("gameOver");
document.getElementById("startreset").innerHTML = "Reset Game";
startCountdown();
generateQA();
}
}
function startCountdown() {
action = setInterval(function () {
timeremaining -= 1;
document.getElementById("timeremainingvalue").innerHTML = timeremaining;
if (timeremaining === 0) {
stopCountdown();
}
show("gameOver");
document.getElementById("gameOver").innerHTML = "<p>Game over!</p><p>Your score is " + score + ".</p>";
hide("timeremaining");
hide("correct");
hide("wrong");
playing = false;
document.getElementById("startreset").innerHTML = "Start Game";
}, 1000);
}
function stopCoutdown() {
clearInterval(action);
}
function hide(id) {
document.getElementById(id).style.display = "none";
}
function show(id) {
document.getElementById(id).style.display = "block";
}
function generateQA() {
}