get char code javascript code example
Example 1: get ascii value of char javascript
word = userInput[0];
var sum =0;
for(i=0;i<word.length;i++)
{
sum = sum + word.charCodeAt(i);
}
console.log(sum);
Example 2: javascript charcode
const sentence = 'The quick brown fox jumps over the lazy dog.';
const index = 4;
console.log(`The character code ${sentence.charCodeAt(index)} is equal to ${sentence.charAt(index)}`);
Example 3: charcodeAt javascript
const sentence = 'The quick brown fox jumps over the lazy dog.';
const index = 4;
const charcode= sentence.charCodeAt(index);
console.log (charcode);