Day 16: Exceptions - String to Integer

  • + 0 comments

    that is a nonsense. why doesn't work the similar code? ` function main() { const S: string = readLine(); const N = Number(S);

    try {
        if (isNaN(N)) {
            throw new Error("Bad String")
        } else {
            console.log(N)
        }
    } catch(error) {
        console.log(error.message);
    }
    

    } `