Challenge #2 does not produce the correct result: SOLVED


Has anyone solved Challenge 2 yet? The challenge is very easy as the first and I am sure that the logic and code are correct, but the page returns that the code runs but does not return the correct result. Does anyone know if there is any detail I have to pay attention to?


I was a bit bamboozeled as well, as my code was running fine in a browser console. What I had to do to make it work was remove the version of GRID I had in the on-page editor.

It worked fine after that.


I was also bamboozeled! @richjdsmith’s workaround worked for me. Just completely remove the definition of GRID used in the previous exercise so that you’re left with only your two functions getRows and getColumns. :slight_smile:


Glad I could help out!


Problem solved. Thank you all.


How do you remove the version of GRID?


Hi all,

I’m also having trouble with this.

I’ve managed to solve the challenge in two different ways, both of which run just fine in my editor/browser, but when I paste the code into the challenge I get that it does not produce the correct result.

I’ve tried deleting the GRID constant from the on-site code as others have mentioned, but unfortunately get the same result. Am I missing something? Any hints or guidance would be greatly appreciated, and thanks!

  • Mo


I think what helped me the most was thinking of the structure of an array as how the computer sees it (as opposed to how we perceive a two dimensional array or matrix) and how you could pull the the column info from the input GRID. I dont think you need to be defining GRID as a global variable, just be able to create a function that can take the argument GRID.


Are you saying that i cant use GRID.length? Im not completely following what you mean by removing the version of GRID


Not solved for me…lol. What do you mean by removing the version of GRID? I have deleted everything, re-done it all…still the same. Not producing correct result…


I’m lost too, trying to figure out what I’m doing wrong


The solution I got to work was NOT to remove the GRID.length as this defines what you are trying to find; the key was to write a function just like previously however to define the GRID.length function just 1 step more to what you are looking for, try thinking in terms of pulling a set from an array.

That way it worked for me, again, just like Day 1 quite simple I was just way overthinking it.



@TheVoicelessBat is there a good online example? ive tried many things that wont work


Yes, this helped it click for me…look at the first example at the function, the first 2 lines where there the similarities lie is what really helped me figure it out.


I can’t solve this problem. Could you help me?

function countColumns(){
var countColumn = 0;
for(var i = 0; i < GRID.length; ++i){
for(var j = 0; j < GRID[i].length; ++j){

return countColumn;




what wrong in this code plz ???
Your code ran but did not produce the correct result.
why ???
function countRows(){
var meno = GRID.length
return meno;
function countColumns(){
var menc = 0;
var ro = GRID.length;
for(var i = 0; i < ro; ++i){
menc += GRID[i].length;
return menc;


You have to count the columns in only one row. Take the first row and count the columns.


Thank you!! I just took the first row and count the columns and I solved it!!


Awesome, glad you were able to solve it! :sunglasses: :pray:


I can’t find out why my code is not working. It spit out the correct result in the browser console but not in LHL:

function gridSize() {
function countRows() {
return GRID.length;

function countColumns() {
return GRID[0].length;
return '${countColumns()} x ${countRows()}';