Waiting for a button press in a quiz before the answer is revealed

Question:
Is there a way to wait for a button press (to reveal an answer to a quiz question)

Product:
VELO javascript

What are you trying to achieve:
I am writing a scripting quiz where a scenario is presented and then a question is asked. I need to wait for the user to press REVEAL ANSWER, before moving on. I have included my best attempt but the code still immediately presents the answer.

Additional information:
Here is a simplifed version of the code. Any help or advice is appreciated. Thanks!

$w.onReady(function () {})

let buttonClicked = false;
let questionNumber = (9999) //i.e. main menu

$w(‘#topBox’).text = “Question Practice”
cleanBoxes();
$w(‘#scriptChoice’).onChange((event) => {
let choice = event.target.value;
if (choice === “Open House”) {
console.log(choice)
questionNumber = 10
} //end if

//begin the scenario

//open house scenario
if (questionNumber === 10) {
    console.log("Enter Scenario 1 Thread")

    $w('#topBox').text = "Scenario 1"
    $w('#whiteBox').text = "Question one asked here"
    /*The desired outcome is that we wait here for the #revealAnswer button to be pressed.
    However, the code continues to revewal the answer in the yellow box without waiting.
    */
    whatSay();
    revealAnswerButton();

    $w('#yellowBox').text = "Answer 1 here"
    $w('#firstButton').label = "Continue"
}

}) //end onReady

//start of functions

function whatSay(event) {
// Checks if the enter key has been pressed
$w(‘#whatSay’).text = “What do you say to the prospect.”
$w(‘#revealAnswer’).label = “REVEAL Answer!”
}

function cleanBoxes() {
//clears all boxes and buttons to blank
$w(‘#whiteBox’).text = “”
$w(‘#whatSay’).text = “”
$w(‘#revealAnswer’).label = “”
$w(‘#yellowBox’).text = “”
$w(‘#buttonPrompt’).text = “”
$w(‘#firstButton’).label = “”
$w(‘#mainMenu’).label = “”
} //end function

//button scripts below provided by chatGPT

// Function to handle button click
function handleButtonClick() {
buttonClicked = true;
}

// Function to wait for button press
function waitForButtonClick() {
return new Promise(resolve => {
if (buttonClicked) {
resolve();
} else {
// Attach event listener to the button
$w(‘#revealAnswer’).onClick(() => {
handleButtonClick();
resolve();
});
}
});
}

// Call this function whenever you want to wait for the button press
async function revealAnswerButton() {
await waitForButtonClick();
console.log(“Button clicked!”);
}