Всем большое спасибо за столь быстрые ответы! Вот рабочий код:
function calculation() {
var firstNum = prompt('Enter first number: '),
secondNum = prompt('Enter second number: '),
operating = prompt('Enter operating with number: '),
result;
// string to number
var nFirstNum = (+firstNum / 1),
nSecondNum = (+secondNum / 1);
switch(operating) {
case '+':
result = (nFirstNum + nSecondNum);
break
case '-':
result = (nFirstNum - nSecondNum);
break
case '*':
result = (nFirstNum * nSecondNum);
break
case '/':
result = (nFirstNum / nSecondNum);
break
case '':
result = 'ERROR: Values are empty!';
console.log('ERROR: Values are undefined!');
break
default:
result = 'ERROR: Operating is not correct!';
console.log('ERROR: Operating is not correct!');
} // switch
switch(result) {
case undefined:
result = 'ERROR: Calcule is falied!';
console.log('ERROR: Result is undefined!');
break
default:
if(isNaN(result)) result = 'ERROR: Answer is not a number!';
}
alert(result);
};