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,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.