You are viewing a single comment's thread. Return to all comments →
Why does this not work?
function main() { const S = readLine(); var n = S; try{ var m = parseInt(n); if(isNaN(m)){ throw new Error("Bad String") }else{ console.log(m); } }catch(e){ console.log(e.message); } }
But this works?
function main() { var S = Number(readLine()) try { Number.isNaN(S) ? error : console.log(S) } catch (err) { console.log('Bad String') } }
`
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 →
Why does this not work?
But this works?
`