How to check that a string object contains only numbers
You should always validate data entered by user or received from backend before doing any processing on it, for example if you are expecting a string object that contains a price or quantity then this string must include only digits.