Good afternoon guys,
I received an assignment from my school. The task is not that hard, but due the lack of explanation from my teacher, I am very stuck.
The assignment is:
You create an input field. In the input field you write 3 numbers. For example 2, 3, 5. The numbers are split by the ','.
Then you have a select, with the values - , +, / and *. So if you select + and then click the button calculate, it will do 2 + 3 + 5 and then show the answer.
This is my code right now.
<body>
<h1>Calculate</h1><br>
Numbers: <input type="text" name="fill" id="fill"><br><br>
Operation:
<select name="select" id="select">
<option value="plus">+</option>
<option value="min">-</option>
<option value="keer">*</option>
<option value="delen">/</option>
</select><br><br>
<button onclick="count()">Count</button>
<div class="answer"></div>
<script>
function count(){
var operator = document.getElementById("select").value;
var string = document.getElementById("fill").value;
var array = string.split(",");
}
</script>
So it reads what's inside the input, it reads what I selected in the select and it knows that I need to split the input with ','.
I am stuck now. Can someone give me a hand?