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 233 views
3 answers 283 views
2 answers 186 views
1 answer 167 views
4 answers 382 views
2 answers 196 views
3 answers 135 views
...