Objective
Write a JavaScript program that uses functions with parameters and return values to perform basic arithmetic operations.
Instructions
- Create a div with the class "calculator".
- Create two <input> of type "number".
- Create a <select> object that allows the user to choose the operation + - * /
- <select id="operation">
- <option value="+">+</option>
- Create a button to submit your data.
- Create four functions:
add(a, b), subtract(a, b), multiply(a, b), and divide(a, b).
- Each function should take two parameters and return the result.
- Write a
main() function that:
- Prompts the user for two numbers and an operation.
- Calls the appropriate function.
- Displays the result.