How to create an array with alphabet letters in JavaScript

2 Answers

0 votes
const alphabetArr = 'abcdefghijklmnopqrstuvwxyz'.split('');

console.log(alphabetArr); 

  
    
    
/*
run:

["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
    
*/

 



answered Sep 18, 2021 by avibootz
0 votes
const ASCII = Array.from(Array(26)).map((en, i) => i + 65);

const alphabetArr = ASCII.map((ch) => String.fromCharCode(ch));

console.log(alphabetArr); 

  
    
    
/*
run:

["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
    
*/

 



answered Sep 18, 2021 by avibootz

Related questions

3 answers 332 views
2 answers 130 views
3 answers 188 views
2 answers 174 views
2 answers 183 views
2 answers 172 views
1 answer 193 views
...