Stuck on Challenge 18, help please [solved]


#1

So far my code reads:

function howDangerous(coordinate) {if (isRock(coordinate)) return 100;
else if (isCurrent(coordinate)) return 50;
else {return 0;}
}

Can anyone provide input as to what I’m doing wrong?

TIA


#2

Let me try and parse your code for you here…

function howDangerous(coordinate) {
  if (isRock(coordinate)) return 100;
  else if (isCurrent(coordinate)) return 50;
  else {
    return 0;
  }
}

As a note, 4 spaces and then your code will do the above pre-formatting so it is more readable!

Upon first inspection, your code looks fine. I also tested it with my isRock and isCurrent functions and it seems to work correctly. What is the error message that you are getting?


#3

@karcar you could do this instead:

function howDangerous(coordinate) {
	if (isRock(coordinate)) return 100;
	if (isCurrent(coordinate)) return 50;
	return 0;
}

#4

The error message I’m getting is:

Your code ran but did not produce the correct result.


#5

Hmm… that isn’t working either… I’m beginning to think I have something incorrect with isRock() or isCurrent()


#6

@karcar

I have seen a few threads reference a broken lightcell() or isRock() etc after the challenge where we had to go back and implement a check for proper input. I would suggest looking back through all relevant functions which your new function utilizes. :slight_smile:


#7

Thank you! It was the updated lightCell() function that was causing the error. Once I corrected for the updated version, I was able to solve the challenge!