Here is a code sample with an array of cars:
<html>
<body>
<script type="text/javascript">
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
var x = 1;
document.write("Value of x: " + x + "<br /><br />");
for (x in mycars)
{
document.write(x + ": " + mycars[x] + "<br />");
}
document.write("<br />Value of x: " + x + "<br />");
document.write("Number of cars: " + mycars.length);
</script>
</body>
</html>
The output currently shows all the elements in the array, including the first one.
Is there a way to modify the code without changing the loop structure so that only some items are displayed?