Created
May 10, 2016 03:16
-
-
Save makshark/999e4386aaad8b6ba5523f3bb17f59b1 to your computer and use it in GitHub Desktop.
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
function calc(n1, op, n2, n3) { | |
switch (op) { | |
case '+': | |
return ((n1 + n2) === n3); | |
case '-': | |
return ((n1 - n2) === n3); | |
case '*': | |
return ((n1 * n2) === n3); | |
case '/': | |
if (n2 === 0) { | |
return false; | |
} | |
return ((n1 / n2) === n3); | |
default: | |
return 'Неправильный знак, можно использовать только *, /, +, - '; | |
} | |
} | |
console.log(calc(1, '+', 2, 3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment