Skip to content

Instantly share code, notes, and snippets.

@sealucky7
Created January 2, 2019 08:30
Show Gist options
  • Save sealucky7/242993cd4834731d8ec3ca8a1ebc923b to your computer and use it in GitHub Desktop.
Save sealucky7/242993cd4834731d8ec3ca8a1ebc923b to your computer and use it in GitHub Desktop.
function calc( a, b, c) {
if ( isNaN(a) ) {
console.log("Первый аргумент не число!");
}
if ( isNaN(b) ) {
console.log("Второй аргумент не число!");
}
switch (c) {
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
default:
console.log("Передайте один из символов математической операции +, -, * или /");
}
}
console.log(calc(10, 3, '*'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment