Thread: Help Array!!!!!
View Single Post
Old 12-30-2012, 04:21 AM   PM User | #9
jmrker
Senior Coder

 
jmrker's Avatar
 
Join Date: Aug 2006
Location: FL
Posts: 2,764
Thanks: 29
Thanked 453 Times in 447 Posts
jmrker will become famous soon enough
Question

Quote:
Originally Posted by triko View Post
Yes using your first method, im solve alone but now i have an other problem
All code is write right but, remainder is NaN and evenOdd don't have value of "i"
Code:
function exchangeSymmetric ()
{
    var arrayPrincipal = [4, 2, 13, 0, 5];
    var array1 = [];
    var array2 = [];
    for (i = 0; i < arrayPrincipal.length; i++)
    {
        var evenOdd = array1 [i];
        var remainder = evenOdd%2;
    }
    alert (remainder);
}
Your code makes no sense to me.
You create an arrayPrinciple and use the length in a for...loop,
but you never check its contents.

When you make an assignment to the evenOdd variable,
you are using an element position in an empty array1 ... hence the NaN error.

You save the last remainder of the tests which is what becomes alerted,
but it is outside the for...loop which is why only one alert occurs.

What is it that you are really trying to accomplish?
jmrker is offline   Reply With Quote