Integer to Capital characters conversion
Example: Using both from CharCode() and, charCodeAt() methods
Javascript
let example = (integer) => { let conversion = "A" .charCodeAt(0); return String.fromCharCode( conversion + integer ); }; // Integer should 0<=intger<=25 console.log(example(6)); console.log(example(5)); console.log(example(6)); |
Output
G F G
Example: Using only fromCharCode() method
Javascript
let example = (integer) => { return String.fromCharCode( 65 + integer ); // Ascii of 'A' is 65 }; console.log(example(6)); console.log(example(5)); console.log(example(6)); |
Output
G F G
How to Convert Integer to Its Character Equivalent in JavaScript?
In this article, we will see how to convert an integer to its character equivalent using JavaScript.
Contact Us