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)]
htmlAnswer = /*HTML*/ `
<div>Question: </div><br>
<div>Question: ${question}</div><br>
<div>Answer: ${randomAnswer}</div>
`;
clearScreen();

View file

@ -19,7 +19,7 @@ const negativeAnswers = [
];
var html = /*HTML*/`
<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>
`;
var htmlAnswer = '';
@ -27,3 +27,4 @@ var htmlAnswer = '';
var answerArray = [];
var randomAnswersArrary = [];
var randomAnswer;
var question;