Nonsense error message. Bug?


#1
var moonPhase = 'full';

if (moonPhase.toLowerCase() === 'full') {
  console.log('Howl!');
} else if (moonPhase.toLowerCase() === 'mostly full') {
  console.log('Arms and legs are getting hairier.');
} else if (moonPhase.toLowerCase() === 'mostly new') {
  console.log('Back on two feet');
} else {
  console.log('Invalid moon phase');
}
Did you write an else if statement for if the moonPhase is mostly new?

seems to be a lot of times where i do exactly what the instructions say and it thinks i haven’t. am i going insane or what?


#2

why did you convert to lowercase? doing more then the instructions asks of you, can trick error messages


#3

Midly obsessive habit of adding bits where they should be added.

EDIT: it uh… yeah it was that. i cant figure out why it would be a problem tho… i guess i will just suck it up and move on. Really frustrating though.


#4

Hi @dococksfart,

Hope you don’t mind me chip in a little. It’s great to know that there is some tinkering done with the lesson’s code to make some variation of it, it shows that you’re enthusiastic to try new things and have a curious mind.

Like @stetim94 mentioned, it is always a good call and better to follow what the instructions asked in the lessons. To be precise, just copy whatever sentences or variable names those lessons asked for, all that is done to avoid the frustration of not passing the lessons due to different spelling, spaces or capitalization (You might be surprise some hurdles was due to spelling differences like favourite vs favorite, which caught some users off-guard). By doing all that, if you encounter not passing lessons, you can eliminate those errors above and start debugging your code to see where it might be coded wrongly, it will save some time for you in future.

That said, if you’re considering about tinkering those code you have in your lessons, you can copy the code and paste it into a site like repl.it to change and play with the variations you like and see if those changes you make will be working or not.


Small suggestion and opinion:

In the current state, .toLowerCase() does nothing in your code. Since you already assigned full in all small-caps to variable moonPhase :

var moonPhase = 'full';

(It’s a bit redundant to test for lower case again using .toLowerCase(), I guess that’s why the author of the lesson omitted it)

However, you can consider adding a prompt in the code to trigger for user input, then, .toLowerCase() could prove its usefulness as user might type in something like "FULL" / "Full" etc.

Nonetheless, all these opinions are only for your side-project outside of CC learning environment. During the learning lesson in CC, just stick to what is instructed and follow those instructions accordingly. You will progress with less hurdle that way.

Happy Coding! :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.