-
-
Save McLarenCollege/9ae8a9c0503ae36db416eaf6319ff795 to your computer and use it in GitHub Desktop.
Calculator
This file contains 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
/* | |
You are required to create a simple calculator that returns the result of addition, subtraction, multiplication or division of two numbers. | |
Your function will accept three arguments: | |
The first and second argument should be numbers. | |
The third argument should represent a sign indicating the operation to perform on these two numbers. | |
if the sign does not belong to the list above a message "unknown operator" must be returned. | |
*/ | |
// Example: | |
calculator(1,2,"+"); //=> result will be 3 | |
calculator(1,2,"&"); //=> result will be "unknown operator" | |
calculator(1,2,"*"); //=> result will be 2 | |
calculator(4,2,"/"); //=> result will be 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment