Separating an Array
|
|
<html> <head> <title>Separating an Array</title>
</head> <body>
<h1>Separating an Array</h1>
<script language="javascript" type="text/javascript"> <!--
var ages = new Array(12,57,32,6,21,19); ages = ages.reverse();
var adults = new Array(); var minors = new Array();
while (ages.length) { var tempAge = ages.pop(); if (tempAge < 21) minors.push(tempAge); else adults.push(tempAge); }
alert(minors); alert(adults);
//--> </script>
</body> </html>
|
|
|
HTML code for linking to this page:
Related in same category :
-
-
|
|