Skip to content

Convert character to ASCII code in JavaScript

String.prototype.charCodeAt() method in JavaScript returns the ASCII code of a character from a string. It accepts the index of the characters as an argument and returns the ASCII equivalent of it.

let str = "poopcode";
console.log(str.charCodeAt(0)); //112

let str1 = "123";
console.log(str.charCodeAt(0)); //49
See also  Jesse and Cookies - Hackerrank Challenge - Java Solution

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.