create a loop that prints the alphabeth in javascript

Here's how you can use a for loop to print the alphabet in Javascript:

index.tsx
for (let i = 97; i <= 122; i++) {
   console.log(String.fromCharCode(i));
}
76 chars
4 lines

In this loop, i starts at the Unicode value for lowercase a (97) and ends at the Unicode value for lowercase z (122). The String.fromCharCode() method then converts each Unicode value to its corresponding character and prints it to the console.

related categories

gistlibby LogSnag