Assignment
Create a calculator program with functions that:
- Has a function called
addthat takes two numbers as parameters and returns their sum - Has a function called
subtractthat takes two numbers as parameters and returns their difference - Has a function called
multiplythat takes two numbers as parameters and returns their product - Has a function called
dividethat takes two numbers as parameters and returns their quotient (handle division by zero) - Has a function called
calculatethat takes three parameters: num1, num2, and operation ('add', 'subtract', 'multiply', or 'divide') - The
calculatefunction should use if/else or switch to call the appropriate function - Test your calculator with at least 3 different operations
Requirements:
- Use function declarations (function keyword)
- Display results using console.log()
- Handle division by zero (return "Cannot divide by zero" or similar)
- Use prompt() to get user input for numbers and operation
- Use an external JavaScript file (script.js) linked to your HTML
Create an index.html file and a script.js file with your solution.