The reason you are getting null in the array is that you are NOT assigning anything
to the even/odd arrays when the test array is odd/even.
Those positions are not defined when the test fails,
and then you are skipping over the element positions
when you increment the 'i' variable.
The should be you "final code"
Code:
<!DOCTYPE HTML>
<html>
<head> <title> Selection </title>
<script type = "text/javascript">
var arrayPrincipal = [4, 2,53, 4, 12, 7, 20, 13, 0, 5];
function evenOdd () {
var arrayEven = [];
var arrayOdd = [];
for (i = 0; i < arrayPrincipal.length; i++) {
if (arrayPrincipal[i]%2==0) { arrayEven.push(arrayPrincipal[i]); }
else { arrayOdd.push(arrayPrincipal[i]); }
}
alert ("This is Array Even" + " " + arrayEven.join (" ")+"\nThis is Array Odd" + " " + arrayOdd.join (" "));
}
</script>
<body>
<button type = "button" onclick = "evenOdd()"> Build Symmetric </button>
</body>
</html>