function string_to_hex(str) {
let arr = [];
for (let i = 0, len = str.length; i < len; i ++) {
const hex = Number(str.charCodeAt(i)).toString(16);
arr.push(hex + ' ');
}
return arr.join('');
}
console.log(string_to_hex("node.js"));
/*
run:
6e 6f 64 65 2e 6a 73
*/