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 386 views
3 answers 428 views
2 answers 293 views
1 answer 243 views
4 answers 550 views
2 answers 303 views
3 answers 281 views
...