I'm iterating through an array with a for loop. Here's the code:
for (var i in monsters) {
if(i == monsterName) {
newEnemyName = i;
Debug.Log (i + 1);
}
}
Now, here's the problem: I want to print the variable in the array after the current one. If I do `i + 1` like in the code, I just get the output of i (let's say troll) with a one on the end, like this: Troll1. How do I print the variable that comes after i?
Thanks - Elliot "The Question Asker" Bonneville
P.S. I've been struggling with a particularly knotty problem for about two days now, so I've been asking a lot of questions about arrays and forloops. Please forgive me. :)