JavaScript:
function endGame() {
clearInterval(countdown);
clearInterval(moleInterval);
gameOver = true;
alert(`Game Ended!\nYour final score: ${score}`);
if (typeof State !== 'undefined') {
State.variables.money = (State.variables.money || 0) + score;
console.log(`Updated money: ${State.variables.money}`); // For debugging
}
timer = 60;
scoreDisplay.text(`Score: ${score}`);
timerDisplay.text(`Time: ${timer}s`);
startButton.prop('disabled', true); // Disable the start button
endButton.prop('disabled', true); // Disable the end button
}