Challenge 11 - help, I'm so close, this just won't work!


#1

Here’s what I ran. In my console, it produces the correct answer as the last of 10 iterations over the loop. What am I doing wrong? Thanks!

function lightColumn(letter) {

var list = [
‘A’,
‘B’,
‘C’,
‘D’,
‘E’,
‘F’,
‘G’,
‘H’,
‘I’,
‘J’,
‘K’,
‘L’,
‘M’,
‘N’,
‘O’,
‘P’,
‘Q’,
‘R’,
‘S’,
‘T’,
‘U’,
‘V’,
‘W’,
‘X’,
‘Y’,
‘Z’
]

var indexNum = list.indexOf(letter);

var findColumn = [];

for (let i = 0; i < GRID.length; i = i +1) {

findColumn.push(GRID[i][indexNum]);

return findColumn;

}

}

lightColumn(‘C’);


#2

Could it be that you are returning your array inside your for loop? “return findColumn” shouldn’t happen until the for loop is done (after the ‘}’ )


#3

Thank you!! I did that and it worked!! This morning, of course, taking away a buffer day. But thanks so much & all the best as you work through these!


#4

Yeah - I had a problem with an earlier challenge and got held back a day too. I hate it when that happens :frowning: