Challenge 4-am I overthinking this?


#1

Am I overthinking this? Did nobody else draw a blank or can’t quite get it like me?


#2

You probably are :).

One of the hallmarks of programming is that simple is better. It’s better to understand, easier to maintain, and oftentimes more efficient for our computers to run.

In challenge 1 you wrote a function for counting the number of rows in your grid.
In challenge 2 you wrote a function for counting the number of columns in your grid.

In Javascript, you can call functions inside other functions! In this case, 90% of the work you should need you’ve already written :).

Hint: multiplication in Javascript is done using the * operator.

return 10 * 10 would return 100


#3

so something like this? Am i repeating the same type of equation from challenge 3, only putting in the numbers? Also, I have NO IDEA what to include after return.

function totalCells() {
var width = countColumns();
var height = countRows();
var area = 10 * 10;
return
}


#4

You are so close!! Think about what answer the challenge is looking for and remember that you can return variables.


#5

This doesn’t work? Hmmm…am I way off?

function totalCells() {
var width = countColumns();
var height = countRows();
var area = 10 * 10;
return area;
}


#6

or this?

function totalCells() {
var width = countColumns();
var height = countRows();
var grid = 10 * 10;
return grid;
}


#7

You are so close. Yes you want to return the area, but you are hard coding the area variable (10 * 10). You want anyone to be able to get the area of any grid with this function. What if I had a grid size of 15 columns and 5 rows?


#8

GOT IT! Thanks guys!


#9

Nice work! Glad to hear you got it.