Looping Array Elements

<div id="languages"></div>
<script>
var text;
var languages = ['c','c++','java','perl'];
var array_length = languages.length;
text = "<ul>"
for (var i=0; i<array_length; i++)
{
text = text + "<li>" + languages[i] + "</li>";
}
text = text + "</ul>";
document.getElementById("languages").innerHTML = text;
</script>

Share This: