I need to convert a floating number to a string array, for example var num=25.67 into var str_array[0] = '2', str_array[1]='5', str_array[2]='.', str[3]='6'; str_array[4]='7' .
Please show your code. Thank you very in advance.
I need to convert a floating number to a string array, for example var
Share
It’s easy. You just have to convert the
numvar into an string (with the.toString()method) and then.split('')it (the ” parameter makes it split every character).You can also use this code:
Then
str_arraywill be no more an array, but a string (which can be treated as an array)