How to convert a string to equivalent integer value based on ASCII codes in Javascript

Hi Guys,

Here is a quick tip if you would like to convert a string into a sum of ASCII codes for all characters

Function you can use

For ES5:

We can do equivalent in ES6 in

There are times when you would need to know the integer value of the string, be it in sorting or any other scenario, this function will help you out. If this code can be improved. please do let me know, I hope this helps,

VN:R_U [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:R_U [1.9.22_1171]
Rating: 0 (from 0 votes)

Leave a Reply