Checking if string is numeric in Typescript and Javascript
I came across a problem of converting a char value to a number when I was working with Javascript. The interesting thing was that the solution just wasn’t as obvious as I initially thought. In this post, I will talk about how I solved the problem and why did I come across it in the first place. Background In a previous post , I mentioned how I was solving a bunch of recursive problems on CodingBat.com! Well…I had a bit too much fun with it and I decided to extend the fun by solving string problems as well. Solving the string problems was good easy fun, until I came across a minor issue. Issue The problem I was trying to solve was sumDigits . It’s a simple problem i.e. As I mentioned in my previous post and as you can see, CodingBat is focused on Java. However, the problem description is fairly generic and can be solved in any language. When writing the code for this problem the first thing that I thought of was Math.abs . For anyone who’s wo...