'+ userScore +'
out of'+ questions.length +'
'; scoreText.innerHTML = scoreTag; //adding new span tag inside score_Text } else if(userScore > 1){ // if user scored more than 1 let scoreTag = 'and nice 😎, You got'+ userScore +'
out of'+ questions.length +'
'; scoreText.innerHTML = scoreTag; } else{ // if user scored less than 1 let scoreTag = 'and sorry 😐, You got only'+ userScore +'
out of'+ questions.length +'
'; scoreText.innerHTML = scoreTag; } } function startTimer(time){ counter = setInterval(timer, 1000); function timer(){ timeCount.textContent = time; //changing the value of timeCount with time value time--; //decrement the time value if(time < 9){ //if timer is less than 9 let addZero = timeCount.textContent; timeCount.textContent = "0" + addZero; //add a 0 before time value } if(time < 0){ //if timer is less than 0 clearInterval(counter); //clear counter timeText.textContent = "Time Off"; //change the time text to time off const allOptions = option_list.children.length; //getting all option items let correcAns = questions[que_count].answer; //getting correct answer from array for(i=0; i < allOptions; i++){ if(option_list.children[i].textContent == correcAns){ //if there is an option which is matched to an array answer option_list.children[i].setAttribute("class", "option correct"); //adding green color to matched option option_list.children[i].insertAdjacentHTML("beforeend", tickIconTag); //adding tick icon to matched option console.log("Time Off: Auto selected correct answer."); } } for(i=0; i < allOptions; i++){ option_list.children[i].classList.add("disabled"); //once user select an option then disabled all options } next_btn.classList.add("show"); //show the next button if user selected any option } } } function startTimerLine(time){ counterLine = setInterval(timer, 29); function timer(){ time += 1; //upgrading time value with 1 time_line.style.width = time + "px"; //increasing width of time_line with px by time value if(time > 549){ //if time value is greater than 549 clearInterval(counterLine); //clear counterLine } } } function queCounter(index){ //creating a new span tag and passing the question number and total question let totalQueCounTag = ''+ index +'
of'+ questions.length +'
Questions'; bottom_ques_counter.innerHTML = totalQueCounTag; //adding new span tag inside bottom_ques_counter }