I'm trying to make function that check strings. If the string is number, then it will convert it as float. else, it will keep it as it is.
For example: I have these test strings:
"123" => 123
"12.3" => 12.3
"12.300" => 12.3
"test123" => "test123"
"123test" => "123test"
"12.3test" => "12.3test"
"123@123.123" => "123@123.123"
I tried to make it by self as written bellow but sometime it convert real strings to numbers by remove the letters and keep the first part of string numbers
let mynumber="123test@gmail.com"
mynumber = parseFloat(mynumber) ? parseFloat(mynumber) : mynumber;
//output: 123