Use while loop to output all elements in an array : while : Statement JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Statement » while »

 

Use while loop to output all elements in an array

















<html>
<head>
<title>Use while loop to output all elements in an array</title>
</head>
<body>

<h1>Use while loop to output all elements in an array</h1>

<script language="javascript" type="text/javascript">
<!--

var ages = new Array(12,57,32,6,21,19);
var i=0;
while (ages.length) {
  var tempAge = ages.pop();
  document.write("<P>" + tempAge + "</p>");
}
//-->
</script>

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Statement
» while