How to generate an array of the alphabet letters in JavaScript

3 Answers

0 votes
const s = "abcdefghijklmnopqrstuvwxyz"
  
let alphabet_letters = s.split(""); 

console.log(alphabet_letters);  


 
/*
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 Mar 26, 2017 by avibootz
edited May 24, 2024 by avibootz
0 votes
let alphabet_letters = [];
 
for (let i = 97; i <= 122; i++) {
    alphabet_letters.push(String.fromCharCode(i));
}
     
console.log(alphabet_letters);  


       
/*
 
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 Mar 26, 2017 by avibootz
edited May 24, 2024 by avibootz
0 votes
let alphabet_letters = [];
 
for (let i = 97; i <= 122; i++) {
    alphabet_letters.push(String.fromCharCode(i));
}

for (let i = 0; i < alphabet_letters.length; i++) {
    console.log(alphabet_letters[i]);   
}


       
/*
 
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 Mar 26, 2017 by avibootz
edited May 24, 2024 by avibootz

Related questions

2 answers 202 views
3 answers 178 views
2 answers 166 views
2 answers 175 views
2 answers 165 views
1 answer 186 views
4 answers 371 views
...