Day 7 challenge - code ran but did not produce correct result


#1

I am struggling with moving onto the next challenge. My code runs perfectly and gives the correct results when I test it in an editor but does not go through on the site. I read through all other posts but it still does not work. Can someone please point me in the right direction?


#2

Challenge 7 is isRock, correct? I have only one line of code in that function, and I call on lightCell.


#3

yes thats right. I call on lightCell. Below is the code. It runs but says did not produce correct result. What am I doing wrong?

var rockCell=lightCell(rock);
if(rockCell==’^’)
{
return true;
}
else
{
return false;
}


#4

Three things.

First: make sure you’re passing the parameter to your function. I used CELL in both lightCell and isRock. Some folks called it coordinate instead. It looks like you’re calling it rock here, but you might find it easier to call it the same thing in both functions, especially since you don’t yet know whether it’s a rock or not.

Second: check the quotes you’re using to see if they’re straight or angled. Angled or curly quotes will NOT work in JavaScript. The ones you’ve pasted here are ’^’ but you should be using '^'

Third: you can make the structure much simpler. There are a couple ways to do this. I have:

function isRock(CELL) {
 return lightCell(CELL) == "^";
}

This will return true or false depending on the value of the cell.

If none of these help, there might be a problem with your lightCell function.