Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 4, 2023 14:57
Show Gist options
  • Save suhailgupta03/898186038b4bbb96feeae7b9cd943d69 to your computer and use it in GitHub Desktop.
Save suhailgupta03/898186038b4bbb96feeae7b9cd943d69 to your computer and use it in GitHub Desktop.
function calculator(operation, a, b) {
if(operation == "add") {
return a + b;
}else if(operation == "subtract") {
return a - b;
}else if(operation == "multiply") {
return a * b;
}else if(operation == "divide") {
return a / b;
}else {
return "Invalid operation";
}
}
console.log(calculator("add", 2, 3))
console.log(calculator("subtract", 2, 3))
console.log(calculator("multiply", 2, 3))
console.log(calculator("divide", 2, 3))
console.log(calculator("modulus", 2, 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment