Categories
Teaching course

JavaScript: convert String to Hex code

Below function takes parameter as string and provide result in the form of Hex code.

function hexEncoderFun(str) {
var result = ”;
for (var i=0; i<str.length; i++) {
result += str.charCodeAt(i).toString(16);
}
return result;
}