startit/oppgaver/uke6/8ball/controller.js

17 lines
511 B
JavaScript
Raw Normal View History

2024-09-16 10:41:14 +02:00
function pickRandomAnswer(){
answerArray = [AffirmativeAnswers, nonCommittalAnswers, negativeAnswers];
randomAnswersArrary = answerArray[Math.floor(Math.random() * answerArray.length)];
randomAnswer = randomAnswersArrary[Math.floor(Math.random() * randomAnswersArrary.length)]
htmlAnswer = /*HTML*/ `
2024-09-16 10:44:45 +02:00
<div>Question: ${question}</div><br>
2024-09-16 10:41:14 +02:00
<div>Answer: ${randomAnswer}</div>
`;
clearScreen();
updateView();
}
function clearScreen(){
app.innerHTML = '';
}