You are viewing a single comment's thread. Return to all comments →
I did it in JS like so:
// Hacky way to generate an exception var i = 1; try { i.toString(parseInt(S) * 0 + 2); // Fails on NaN console.log(S); } catch (err) { console.log("Bad String"); }
You're right though, this challenge is certainly a lot easier in strongly typed languages such as C# or Java.
Seems like cookies are disabled on this browser, please enable them to open this website
Day 16: Exceptions - String to Integer
You are viewing a single comment's thread. Return to all comments →
I did it in JS like so:
You're right though, this challenge is certainly a lot easier in strongly typed languages such as C# or Java.