-The sample code above has two different scenarios, one with a string only consisting of digits and the other with a string consisting of both digits and letters. The first two `parseInt()` and `parseFloat()` methods work normally and converts the whole string into an integer/float. `str_1` and `str_2` are a little more complicated as the string contains letters as well. In this case, the letters after the numbers are ignored. Therefore, "Hello" is ignored when the method is called and `console.log()` messages will print "123" and "12.3" respectively. This is the "strange" behavior exhibited by the `parseInt()` and `parseFloat()` method that you should be aware of when writing your own code.
0 commit comments