Calling the Calculate Function in JS

Report a typo

Given the following JavaScript code snippet, select the correct ways to call the calculate function and pass two numbers as arguments for the calculation. The function accepts an arithmetic operator (+, -, *, /) and two numbers as arguments.

function calculate(operator, num1, num2) {
  switch (operator) {
    case '+':
      return num1 + num2;
    case '-':
      return num1 - num2;
    case '*':
      return num1 * num2;
    case '/':
      return num1 / num2;
    default:
      return 'Invalid operator';
  }
}
Select one or more options from the list
___

Create a free account to access the full topic