lundi 6 juillet 2020

Quiz timer in JavaScript

i am building a quiz in javascript and i want to set the a timer for each question and yet i cant seem to achieve it. Here is my code:

 function start(){
    let correct = 0;
    let incorrect = 0;
    let question = "none";
    let input = "none";
    let answer = "none";
//  the ask function
let ask = function(){
    input = prompt(question); 
};
// the score function 
let score = function(){
    if(input==answer){ // if (condition){ do smtin} else { do smtin}
       correct = correct+1;
       alert("Correct");
 } else{
     incorrect= incorrect+1;
     alert("Incorrect");
 }
};
//  this function calls both the ask and score functions
let both = function(){
    ask();
    score();
};```



Aucun commentaire:

Enregistrer un commentaire