/
Iterating through an array

Iterating through an array

We can use a for loop. This is an example:

var PERSONlist = ["Fred", "Mary", "John"]; var H = ''; for (var i=0; i < PERSONlist.length; i++){ H += "<li>" + PERSONlist[i] + "</li>"" }

In that example we are concatenating strings together to make a list of people.

Related content

Playing around with CSS and Javascript showing the power of the console.
Playing around with CSS and Javascript showing the power of the console.
Read with this
Javascript Arrays
Javascript Arrays
More like this
The Javascript console and Developer Tools in Chrome
The Javascript console and Developer Tools in Chrome
Read with this
How do I join strings together?
How do I join strings together?
More like this
Javascript Concepts - Start Here!
Javascript Concepts - Start Here!
Read with this
Javascript strings are immutable
Javascript strings are immutable
More like this