| Viewed 85 times

How to convert to Hex in javaScript?


Examples toHex("hello world") // "68 65 6c 6c 6f 20 77 6f 72 6c 64"

1 Answer
Mohammad Qandeel
Answered
19

Hexadecimal describes a base-16 number system, what you need is to convert to hex in js

you can try this method 

function toHex(str) {
 return str.split('').map(a => a.charCodeAt(0).toString(16)).join(' ');
}
 


Related Questions