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 Answers
+ 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.