Created
August 4, 2023 14:57
-
-
Save suhailgupta03/898186038b4bbb96feeae7b9cd943d69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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