Write a React component named MathOperator
that renders: two number inputs, a <select>
dropdown between them labeled Choose operator
and a Calculate
button.
The <select>
should have four possible values:
+
-
*
/
When the Calculate
button is clicked, perform the selected operation between the two inputs and show the result in a paragraph like so: Result is: {number}
Example:
21
42
/
Result is: 0.5
If the calculation cannot be performed, render a paragraph with an appropriate message. For example:
Enter both numbers
Cannot divide by zero