2 Example(s) of JavaScript fromCharCode function


Description :

JavaScript fromCharCode() function return Unicode values from characters. See the code snippet:


JavaScript fromCharCode function Example - 1
<!DOCTYPE html>
<html>
 <head>
    <title>Welcome to LearnKode - A code learning platform</title>
</head>
  <body>
<button onclick="convertUnicodeToCharacter()">Display the character</button>
<p id="sample"></p>
<script>
function convertUnicodeToCharacter() {
    var result = String.fromCharCode(65);
    document.getElementById("sample").innerHTML = result;
}
</script>
      </body>
</html>

Output

Description :

Example of JavaScript fromCharCode function:


JavaScript fromCharCode function Example - 2
<!DOCTYPE html>
<html>
 <head>
    <title>Welcome to LearnKode - A code learning platform</title>
</head>
  <body>
<button onclick="convertUnicodeToCharacter()">Display the character</button>
<p id="sample"></p>
<script>
function convertUnicodeToCharacter() {
  var res = String.fromCharCode(72, 69, 76, 76, 79);
    document.getElementById("sample").innerHTML = res;
}
</script>

      </body>
</html>

Output