0

Hello, could you help me. Why my default is not working?

let a=+prompt('first number') let n=+prompt('second number') function calc(a,n,u) { switch (u) { case '-': return a-n; break; case '+': return a+n; break; case '/': return a/n; break; case '*': return a*n; break; default: return('введите действительный номер'); } } console.log(calc(a,n,'-')) console.log(calc(a,n,'+')) console.log(calc(a,n,'/')) console.log(calc(a,n,'*'))

21st Feb 2022, 6:31 AM
ainuska zhumaeva
ainuska zhumaeva - avatar
3 Réponses
+ 1
You are not calling the default. + - * / are all valid values, so the default not reached Add something like Console.log(calc(a,n,z)) Now the default will be called because no matching case. please add the language you use in the tags
21st Feb 2022, 6:43 AM
sneeze
sneeze - avatar
0
still not working
21st Feb 2022, 7:01 AM
ainuska zhumaeva
ainuska zhumaeva - avatar
0
Please elaborate more. What is it that is not working. https://code.sololearn.com/WRqrNq7MVuBA/?ref=app It works in this code.
21st Feb 2022, 11:40 AM
sneeze
sneeze - avatar