How to loop through an array of characters in Node.js

2 Answers

0 votes
const array = ['a', 'b', 'c', 'd', 'e'];
  
for (let i in array) {
    console.log(array[i]);
}
 
 
 
 
/*
run:
  
a
b
c
d
e
  
*/

 



answered Sep 2, 2023 by avibootz
0 votes
const array = ['a', 'b', 'c', 'd', 'e'];
  
for (let i = 0; i < array.length; i++) {
    console.log(array[i]);
}
 
 
 
 
/*
run:
  
a
b
c
d
e
  
*/

 



answered Sep 2, 2023 by avibootz

Related questions

3 answers 203 views
4 answers 201 views
1 answer 148 views
2 answers 172 views
2 answers 168 views
...