Skip to content

Instantly share code, notes, and snippets.

@ethanstenis
Created July 17, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanstenis/75dcc5a703323cee918ebb1eed404976 to your computer and use it in GitHub Desktop.
Save ethanstenis/75dcc5a703323cee918ebb1eed404976 to your computer and use it in GitHub Desktop.
This is the solution to Codewars' KATA: Basical Mathematical Operations
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;
}
}
@andrii-doroshenko
Copy link

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';
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment