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

17 lines
533 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:47:46 +02:00
<div>Your question: ${question}, does not matter</div><br>
2024-09-16 10:41:14 +02:00
<div>Answer: ${randomAnswer}</div>
`;
clearScreen();
updateView();
}
function clearScreen(){
app.innerHTML = '';
}