+ 2

Error handling?

Is there any error handling in JavaScript? I'm making a calculator that uses prompt() to get inputs. But what happens if someone inputs a string as x? The calculator wont work if someone uses 8 as the arithmetic operator. And in this course there is no error handling (try & catch).

20th Aug 2016, 10:51 AM
Oscar
Oscar - avatar
1 Resposta
+ 2
you need to handle it by yourself using instanceof and === in some cases
20th Aug 2016, 11:34 AM
Bogdan