JSFiddle - React, Tailwind, and code Playground

JavaScript

function toHex(str) {
    var result = '';
    for (var i=0; i<str.length; i++) {
      result += str.charCodeAt(i).toString(16);
    }
    return result;
 }
 
 const result = `
 "0123456789": ${toHex("0123456789")}\n
 "πŸ˜€": ${toHex("πŸ˜€")}\n
 "πŸ€·πŸ»β€β™€οΈ": ${toHex("πŸ€·πŸ»β€β™€οΈ")}
 `;
 
 alert(result);