Ive made this:
if( tal[i+1] ){
if( tal[i] == tal[i+1]){
match=true;
}
}
But it doesnt seem to work.
I want to check whether the field next to the current (i) exists, in the array tal[].
How can i fix this?
If by "exists" you mean "is not out of bounds", then you have to check the length:
if (i+1 < tal.length) {
// i+1 is a valid index in tal here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With