How to loop through an array of characters in JavaScript

2 Answers

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




/*
run:
 
"a"
"b"
"c"
"d"
 
*/

 



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





/*
run:
 
"a"
"b"
"c"
"d"
 
*/

 



answered Sep 2, 2023 by avibootz

Related questions

3 answers 232 views
3 answers 279 views
2 answers 180 views
1 answer 166 views
4 answers 380 views
2 answers 194 views
3 answers 133 views
...