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,'*'))
3 Respostas
+ 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
0
still not working
0
Please elaborate more. What is it that is not working.
https://code.sololearn.com/WRqrNq7MVuBA/?ref=app
It works in this code.