How to convert a number to a letter with JavaScript?

Sometimes, we want to convert a number to a letter with JavaScript.

In this article, we’ll look at how to convert a number to a letter with JavaScript.

How to convert a number to a letter with JavaScript?

To convert a number to a letter with JavaScript, we can use the String.fromCharCode method.

For instance, we write:

const i = 5
const c = String.fromCharCode(94 + i);
console.log(c)

We call String.fromCharCode with 94 + i to convert i to a letter.

Therefore, c is 'c' since 97 is the code for 'c'‘ in ASCII.

Conclusion

To convert a number to a letter with JavaScript, we can use the String.fromCharCode method.