Hello, im really new to javascript and having been stuck on a issue for the past hours…i just can’t seem to find a solution, ive tried everything i can think of! i’m stuck with the bolded area, what im intending is to when “position” reaches one of “specialPositionArray” values, “position” then takes the value parallel to specialPositionArray in the index of “connectedPositionArray”.
Any help would be greatly appreciated, i just dont seem to be ableeo think outside the box well enough yet!
function random()
{
return Math.floor(Math.random() * 6) + 1;
}
function findIndexOf(number, numberArray)
{
var indexOfNumber = -1;
for (var position = 0; position < numberArray.length; position = position + 1)
{
if (numberArray[position] == number)
{
indexOfNumber = position;
}
}
return indexOfNumber;
}
var specialPositionArray = [1,7,25,32,39,46,65,68,71,77];
var connectedPositionArray = [20,9,29,13,51,41,79,73,35,58];
random(‘Score’);
document.write(‘Score: ‘ + random(Score) + ‘ ‘);
position = position + random();
document.write(‘Square: ‘ + position + ‘ ‘);
findIndexOf(position, specialPositionArray);
[B][I]if (indexOfNumber == specialPositionArray)
{
document.write(‘move to position: ‘ + position);
}
document.write(‘<BR>’);