I’m trying to solve a tricky problem here. Whenever there are 3 rows together (e.g. 3A, 3B & 3C), I want to increment the variable ‘count’. My logic only works for the first row but then fails for the rest. The answer to this problem should be 3. Can someone shed some light here?
function doThis() {
var everySeat = [1A, 1B, 1C, 2A, 2C, 3A, 3B, 3C, 151A, 151B, 151C, 152B, 152C];
var count;
for (i = 1; i <= everySeat.length; i++) {
if (everySeat[i-1] = i + ‘A’ && everySeat[i] = i + ‘B’ && everySeat[i+1] = i + ‘C’) {
count++;
}
}
}
doThis();
==inifcondition151 and 152values that will never match the condition of your loop3that your are trying to match, youriis now6so youre comparing 3A (everySeat[i-1]) to 6A (i+"A")