queation variable and view

This commit is contained in:
Geir Okkenhaug Jerstad 2024-09-16 10:44:45 +02:00
parent 5e820e89a3
commit e76d0fdcd1
2 changed files with 4 additions and 3 deletions

View file

@ -5,7 +5,7 @@ function pickRandomAnswer(){
randomAnswer = randomAnswersArrary[Math.floor(Math.random() * randomAnswersArrary.length)] randomAnswer = randomAnswersArrary[Math.floor(Math.random() * randomAnswersArrary.length)]
htmlAnswer = /*HTML*/ ` htmlAnswer = /*HTML*/ `
<div>Question: </div><br> <div>Question: ${question}</div><br>
<div>Answer: ${randomAnswer}</div> <div>Answer: ${randomAnswer}</div>
`; `;
clearScreen(); clearScreen();

View file

@ -19,7 +19,7 @@ const negativeAnswers = [
]; ];
var html = /*HTML*/` var html = /*HTML*/`
<div id="ball">8-ball</div> <div id="ball">8-ball</div>
Ask Your question: <input type="text" /><br> Ask Your question: <input type="text" onchange="question = this.value" /><br>
<button onclick="pickRandomAnswer()">Submit</button> <button onclick="pickRandomAnswer()">Submit</button>
`; `;
var htmlAnswer = ''; var htmlAnswer = '';
@ -27,3 +27,4 @@ var htmlAnswer = '';
var answerArray = []; var answerArray = [];
var randomAnswersArrary = []; var randomAnswersArrary = [];
var randomAnswer; var randomAnswer;
var question;