Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a JavaScript file named to implement the following functions as part of your custom module: a . : Takes two numbers as arguments and
Create a JavaScript file named to implement the following functions as part of your custom module:
a : Takes two numbers as arguments and returns their sum.
b 'subtract: Takes two numbers as arguments and returns the result of subtracting the second number from the first.
c 'multiply: Takes two numbers as arguments and returns the result of dividing the first number by the second.
e : Takes a number as an argument and returns its square.
f : Takes a number as an argument and returns its cube.
g 'power': Takes two numbers as arguments and'returns the first number raised to the power of the second.
hsqrt: Takes a number as an argument and returns its square root.
Ensure to export these functions to create a module.
Create a separate JavaScript file named and import the module. Implement a calculator program using the functions from the module as follows:
Display a menu with different mathematical operations.
Prompt the user for their selection and input values if required
Invoke the corresponding function from the module to perform the operation.
Display the result to the user.
Continuously display the menu until the user selects the exit option.
Provide an error message for invalid menu selections and prompt the user until a valid option is chosen.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started