How to create an array of alphabet characters in JavaScript

2 Answers

0 votes
const array = Array.from(Array(26)).map((e, i) => i + 65);

const alphabet = array.map((ch) => String.fromCharCode(ch));
  
console.log(alphabet);
    
    
      
      
/*
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 Aug 23, 2023 by avibootz
0 votes
const array = Array.from(Array(26)).map((e, i) => i + 97);

const alphabet = array.map((ch) => String.fromCharCode(ch));
  
console.log(alphabet);
    
    
      
      
/*
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 Aug 23, 2023 by avibootz
...