//I have an error message "Cannot read property 'value' of null", maybe there are some that can help?
import React from 'react'
function Calculator() {
function Calculation() {
const theValueOne = parseInt(document.querySelector("#valueOne").value);
const theValueTwo = parseInt(document.querySelector("#valueTwo").value);
const theOperator = document.querySelector("#operators").value;
let theCalculation;
if (theOperator === "addition") {
theCalculation = theValueOne + theValueTwo;
} else if (theOperator === "minus") {
theCalculation = theValueOne - theValueTwo;
} else if (theOperator === "multiply") {
theCalculation = theValueOne * theValueTwo;
} else if (theOperator === "divide") {
theCalculation = theValueOne / theValueTwo;
}
document.querySelector("#resualt");
}
return (
<div>
<form>
Value 1: <input type="text" id="valueOne" />
Value 2: <input type="text" id="valueTwo" />
Operator:
<select id="operators">
<option value="addition"></option>
<option value="minus"></option>
<option value="multiply"></option>
<option value="divide"></option>
</select>
<button type="button" onClick={Calculation()}>Calculate</button>
</form>
<div id="resualt"></div>
</div>
)
}
export default Calculator