I want to take from the array (mathematicSymbols) or + or - or * random but i can’t do that as a result i have this issue[9+,-,*11+,-,*2+,-,*10]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!--<script src="node.js"></script>-->
<h1 id="logarithm">Learning maths</h1>
<form action="#" id="myForm">
<label>What is:</label>
<input type="text" id="question" name="question"/>
<br>
<label>The answer is:</label>
<input type="text" id="answer" name="answer"/>
<br>
<label>Correct answer:</label>
<input type="text" id="total" name="total"/>
<br>
<button type="button" name="button" class="button" onclick="genQuestion()">New Question</button>
<button type="button" name="button" class="button" onclick="checkAnswer()">Check Answer</button>
</form>
<script>
var x, y, z, f;
function generateNumbers() {
function getRandom12() {
return Math.floor((Math.random() * 12) + 1);
}
x = getRandom12();
y = getRandom12();
z = getRandom12();
f = getRandom12();
}
let mathematicSymbols = ['+', '-', '*'];
let result = mathematicSymbols.slice(0, 4);
document.getElementById('question').innerHTML = result
function genQuestion() {
generateNumbers();
let question = document.getElementById('question').value = x + result + y + result + z + result + f;
document.getElementById('answer').value = '';
document.getElementById('total').value = '';
}
function checkAnswer() {
alert(
question === +document.getElementById('answer').value ?
'Great!' :
'Not Yet!.'
);
document.getElementById('total').value = question;
}
genQuestion(); // needed for the first time, could be later an event.
</script>
</body>
</html>