function calc() {
var a = parseFloat(document.querySelector("#value1").value);
var b = parseFloat(document.querySelector("#value2").value);
var op = document.querySelector("#operator").value;
var calculate;
if (op == "add") {
calculate = a + b;
} else if (op == "min") {
calculate = a - b;
} else if (op == "mul") {
calculate = a * b;
} else if (op == "div") {
calculate = a / b;
}
document.querySelector("#result").innerHTML = calculate;
}
Value 1: <input type = "text" id = "value 1" >
Value 2: <input type = "text" id = "value 2">
Operator:
<select id = "operator" >
<option value="add">Add</option>
<option value="min">Minus</option>
<option value="mul">Multiply</option>
<option value="div">Divide</option>
</select>
<button type = "button" onclick="calc()" >Calculate </button>
</form>
<div id = "result"> </div>
there are no errors shown but it isnt working and the output doesnt appear