JS Coding Questions Logo
JS Coding Questions
#336💼 Interview💻 Code

How do you convert character to ASCII code

Advertisement

728x90

You can use the String.prototype.charCodeAt() method to convert string characters to ASCII numbers. For example, let's find ASCII code for the first letter of 'ABC' string,

javascript
1"ABC".charCodeAt(0); // returns 65

Whereas String.fromCharCode() method converts numbers to equal ASCII characters.

javascript
1String.fromCharCode(65, 66, 67); // returns 'ABC'

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 79

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
336of476