I am currently working on developing a web game inspired by Duolingo. In a specific scenario, I need a function to be triggered after two button clicks to progress further. However, I am facing challenges in finding solutions online or understanding it on my own since this is my first time working with JavaScript.
For scenarios with a single answer, I have successfully implemented the following function which is executed after a single button press:
function answer (URL) {
setTimeout( function() { window.location = URL }, 3500 );
document.getElementById("answerDisplay").style.display = "inline";
document.getElementById("buttonCorrectAnswer").style.display = "none";
document.getElementById('video').play();
}
I have attempted to address the issue by checking if "answerDisplayOne" and "answerDisplayTwo" are both visible and then calling a function, but have not been successful:
function answerOne() {
document.getElementById("answerDisplyOne").style.display = "inline";
document.getElementById("buttonCorrectAnswerOne").style.display = "none";
}
function answerTwo() {
document.getElementById("answerDisplayTwo").style.display = "inline";
document.getElementById("buttonCorrectAnswerTwo").style.display = "none";
}
if ( $("#answerDisplayOne").css('display') == 'inline' && $("#answerDisplayTwo").css('display') == 'inline'){
function delayTwo (URL) {
setTimeout( function() { window.location = URL }, 3500 );
document.getElementById('video').play();
}
}