i am using the p5js libary and ran into a problem that i have never had before. I have a function called neighbors with the constructor neighbors(x, y). I call that function multiple times each loop (2500 times). If i use this code:
if(x < 50){
if(spots[1][1]){
neighborCount++;
}
}
nothing goes wrong. As soon as i replace the code with this:
if(x < 50){
if(spots[parseInt(x+1)][1]){
neighborCount = 3;
}
}
I get an error in the console:
TypeError: spots[(x + 1)] is undefined
I tried using
spots[parseInt(x+1)][1]
but that only changed the error to
TypeError: spots[parseInt(...)] is undefined
I hope i explained my problem well enough and you can understand it. If i forgot something please tell me i will add it as soon as possible.
Thanks in advance
FritzFurtz
x? And why do you useparseInton what appears to be a number?spots? Does it contain that many items?