Created
July 17, 2017 16:25
-
-
Save ethanstenis/75dcc5a703323cee918ebb1eed404976 to your computer and use it in GitHub Desktop.
This is the solution to Codewars' KATA: Basical Mathematical Operations
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 basicOp(operation, value1, value2) | |
{ | |
if (operation === '+') { | |
return value1 + value2; | |
} else if(operation === '-') { | |
return value1 - value2; | |
} else if(operation === '*') { | |
return value1 * value2; | |
} else if(operation === '/'){ | |
return value1/value2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function basicOp(operation, value1, value2) {
switch (operation) {
case '+':
return value1 + value2;
case '-':
return value1 - value2;
case '*':
return value1 * value2;
case '/':
return value1 / value2;
default:
return 'Please input correct operator';
}
}