Challenge 3 error


#1

i am looking at this since 1 hr cant find error but the challenge says: Your code ran but did not produce the correct result.

(there is one letter gap to the left and right of x)

gridSize=()=> {
return “’”+countColumns.toString()+" x ‘’+countRows.toString()+"’" ;

};


#2

This is what I did… It works in my editor but not on LHL. I even used “typeof” which returns “string” letting me know it’s a string. I also tried using template literals before but didn’t know if it work on LHL.

let width = countRows();
let height = countColumns();

function gridSize(){
    return "'" + width + " x " + height + "'";
}

console.log(gridSize());     -----> '10 x 10'

console.log(typeof(gridSize()));     -----> string

#3

even code is working fine in my editor

in hint its mentioned:watch out spaces

there is single space to the left and right of ‘x’

hope someone will find solution to this


#4

i hope this makes sense:

width is always counted as columns and height as rows

i am totally new to coding(few hrs of yt tutorials) so it was really confusing first:
made it simple:

5 people standing on each other: there height would be measured in rows(1 row is 1 person ) and width will not change

5 people standing next to each other:they are adding columns(increasing width) but are standing in same row(height remains same)


#5

@anoopkular that helped, thanks! I had the width as rows instead of columns, switched them and it passed.It was worded weirdly in the challenge, I kept focusing on the white space, not the variables themselves.


#6

The challenge isn’t quite dynamic enough.

Here is my solution to day 3: https://codepen.io/AJSIM/pen/JmGejz?editors=1111

I successfully console.log “10 x 10”, but still I get rejected.

function gridSize(){
 return ((countRows().toString()) + ' x ' + (countColumns().toString()));
}

We could also do this if we can call the function:

function gridSize(w, h){
 return (w.toString() + ' x ' + (h.toString());
}
gridSize(countRows(), countColumns());

I reversed the function calls as per anoopkular’s great observation. Still no luck.

I finally got it. I refreshed the page, was logged out, logged back in, and submitted the following:

function gridSize(){
 return ((countColumns().toString()) + ' x ' + (countRows().toString()));
}

#7

The above solutions, I feel, were over-thinking it. I tried .toString() as well but I kept getting rejected. So I went into the inspector and thought about how I could simply return a string while also using the already created functions.

The simplest answer always proves to be the best one. If you already have an established function that counts your columns and rows in the grid, then you should not have to do extra work to reestablish that information.


#9

Yes it does. Thanks, solved it.