What do you guys got?

# Challenge 18 ideas [Solved]

**kpalos**#2

I did a two checks on the cell using isRock, and isCurrent from previous challenges. Then I return the appropriate value for each cases where if it is a rock, or if it is a current or it is neither.

**JMNKLS**#3

What is wrong with this logic?

```
function howDangerous(coordinate){
if (isRock(coordinate)) {
return 100;
} else if (isCurrent(coordinate)) {
return 50;
} else {
return false;
}
}
howDangerous('E3');
console.log(howDangerous('E3'));
```

The if (isRock(coordinate)) checks if itâs trueâŚ so based on the previous function, if itâs a rock, it should be true, same for isCurrent.

So if itâs true, it should return 100, for current 50. and for everything else, false.

Currently it returns false.

Any help?

**paulbeaudon**#4

I think the challenge says it has to return a number, try returning 0 instead of false. That may work.

**paulbeaudon**#7

I copied your âhowDangerousâ function into the test environment I was using and your logic gave me:

E1 = false

E2 = 50

E3 = 100

Which is correct.

**JMNKLS**#8

Hmm, so that means that itâs my isRock function that is wrong, or maybe my lightCell functionâŚ

**JMNKLS**#9

Can you check if this worksâŚ(My laptop stopped working and I had to copy the code from lighthouse labs editor and may have made some mistakes.

This is my lightCell functionâŚ It might be a problem from when they asked us to update the lightCell functionâŚ I just made a new one and commented out the first one.

```
function lightCell(coordinate){
return GRID[(convertColumn(coordinate))][convertColumn1(coordinate)];
}
lightCell('B4');
console.log(lightCell('B4'));
```

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

```
function lightCell(coordinate){
if (convertColumn(coordinate) > countColumns()) {
return false;
} else if (coordinate[1] > countRows()) {
return false;
} else {
return true;
}
}
lightCell('Z3');
console.log(lightCell('Z3'));
```

This is my isRock function

```
function isRock(coordinate){
if (lightCell(coordinate) === '^') {
return true;
} else {
return false;
}
}
isRock('D1');
console.log(isRock('D1'));
```

**C_Slater**#11

Just to confirm you have changed your last else statement which contains your final return statement from:

**return false;**

to

**return 0;**

Not sure about the return value type when the LHL code check runs, but if they are looking for an integer returned then your return of false may be the issue.

**C_Slater**#12

Sorry, I forgot to mention, I have a similar structure that returns 0 (as an int) and my code passed.

**JMNKLS**#13

Yep I changed to zeroâŚ Now I think it might have to do with my lightCell function. I might have fucked up when I updated it.

**Steever**#15

THANK YOU THANK YOU THANK YOU!! I completely forgot we changed the lightCell function from before! That had me stuck. What I did was I went around the calling up of the isRock AND isCurrent functions and just converted the coordinates, pulled up the contents from GRID, and then did the logic checks (i.e GRID[i][j] === â^â) in the if statements.

**JMNKLS**#16

Ok, so I changed, some stuff, now it works on the editor, but i had to remove my updated lightCell function and just keep the base one.

So it means itâs the update on the lightCell function who was creating a problemâŚ At least now i know what to look at.

**JMNKLS**#17

SOLVED IT !!!

Thanks everybody for the help!!!

So essentially, I made a mistake while converting the Rows to -1 to adjust for the â0 Indexingâ, which carried on to the rest of the codeâŚ And then, I didnât update properly the lightCell function.

Everything is good now.

**Emayenvyi**#18

Did you revert back to the original code for lightCell (the one used before the update)? Does doing that affect our previous challenge outcome?

**JMNKLS**#19

Before this challenge, I had two lightCell functions. One that would return what was at a certain coordinate in the GRID, and one that would return false if the coordinate given (either letter or number) wasnât part of the GRID.

So I ended up just combining both together as I think was the way to do it initially (but couldnât figure it out at the time for some reason).

So now I only have one that returns false if the column given is larger then the actual number of columns; returns false if the number of rows given is larger then the actual number of rows; and returns what is at that position if the coordinate is good.