im trying to compare between two arrays, whether they have same value at same place, same values at different places or not the same at all. after comparing I want to enter a char to a third array to indicate the result. my code doesnt work for some reason... its not comparing correctly. what am i doing wrong?
var numInput = [1,2,3,4];
var numArr = [2,5,3,6];
var isBp;
var i,j;
for ( i = 0; i < 4; i++)
{
if (numInput[i] == numArr[i])
{ isBP[i] = "X"; }
else
{
for ( j = 0; j<4; j++)
{
if (numInput[i] == numArr[j])
{isBP[i] = "O";}
else
{ isBP[i] = "-"; }
}
}
}
the result should be:
isBP = [O,-,X,-]