Help with Challenge 3


#1

Hey! I need some help with the third challenge. I have tried so many solutions, but when I run the code, it fails every time.
This is my code:

const countRows = () => {
		return GRID.length;
	};
	const countColumns = () => {
		return GRID[1].length;
	};
	const gridSize = () => {
		return `"${countRows().toString()} x ${countColumns().toString()}"`;
	};
	countRows();
	countColumns();
	gridSize();

Not sure what I’m doing wrong. Can anyone help me? Thanks! :slight_smile:


#2

Hey, the question asks us to write just the function so you don’t need to call all 3 at the end. Also, you can make the return of gridSize() easier by using concatenation. e.g widthvalue + " x " + rowvalue. Hope that helps.


#3

@TizzleLizzle Thanks! Do we have to place parameters (rows, cols) in the gridSize function? When you call gridSize(), is it expecting arguments (which would be the countRows and countColumns functions?


#4

Nevermind, I solved it! Thanks for your help @TizzleLizzle


#5

That’s great. Glad I could help.


#6

Why isn’t this working?

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


#7

Hey, I don’t know if this is too late but you don’t need the toString()'s .Since you’re already concatenating, you can combine different data types with a +. And don’t forget to wrap what you’re returning in parenthesis.


#8

Alright I did this but it’s not working:
return {countRows() + " x " + countColumns()};


#9

You’re almost there! Do you want to return column x width or width x column?

Edit: sorry I meant to say height instead of column.


#10

Oh man, okay, thanks!