Can anybody give me a little advice please?
I have a string, for example “01001011” and what I need to do is to reverse it, so I used .split('') than .reverse() and now I need to read the array as a string and convert it to integer. Is it possible?
Thanks
If you want to convert the array back to a string use
join()(MDN) and for converting a string to an integer useparseInt()(MDN). The second argument of the later is an optional radix.JavaScript will try to determine, what radix to use, but to be sure you should always add your radix manually. Citing from MDN:
So in your case the following code should work:
or just (if you would want to convert the starting string, without the reversal):