Problem with Challenge 3


#1

Do I need to rewrite the code from previous challenges?
When I am trying to call my prewritten function into new code its throwing error as
“Your code could not run: “countRows is not defined””


#2

Yeah I think this is a problem. I previously though that we would get a new editor every challenge, but turns out you keep the same editor the whole time, so if you delete stuff in challenge two, you won’t have it in challenge three.

What I’m doing, is I’m also doing it on the side in my editor so I can check for errors and keep it as a back up.


#3

Keep the code for each of the challenges so it builds on each other!


#4

Thanks guys. I completed the challenge. slight_smile:


#5

How did you fix the problem? I am having the same issue with countColumns being undefined


#6

Copy all your previous code into the editor. You should keep all your previous work for each challenge.


#7

Yes! Previous code needs to be copied.


#8

the code is auto saved
when you ll do challenge 2,challenge 1 should be there…


#9

What´s wrong?
Your code ran but did not produce the correct result.
function countColumns() {
return (GRID[0].length);
}
function countRows() {
return GRID.lenght;
}
function gridSize() {
var columns = String(countColumns());
var rows = String(countRows());
var res = columns + " x " + rows;
return (res);
}


#10

What is wrong with this?

return countRows().toString() + " x "  + countColumns().toString();

#11

I don’t know if you copy pasted it or wrote it but your second return says lenght instead of length.

Hope this helps.


#12

You have to do “width x height”.
Rows is the height and columns is the width. Try switching them up.

Hope this helps.


#13

how do you do it on the side in the editor? Are you talking about the console? every time I try to use it none of the codes I write do anything and they always return as undefined. Am I missing something?


#14

Srsly, this, can’t belive that was the problem… Thank you!


#15

I personally use Visual Studio Code. I write the code there and open it in “live server” and use the console on that page (That’s just what I’m used to).

Essentially at this point in the challenge, you should have 4 functions in your screen (Lighthouse labs editor). countRows(); countColumns(); gridSize(); plus the last one whatever you called it.

Try copy/pasting your code so we know what is undefined.


#16

Oh sorry!! I wasn’t clear. My codes all work fine. It’s when I try to so anything in the console to play with the code that none of it work. I read in another forum that it’s because we have to input the code of the grid first but I can’t seem to get that to work either.