How do you write correctly formatted switch code in regards to the werewolf instructions?


#1
let moonPhase = 'full';
switch (moonPhase) {case 'full':
console.log('Howl!');
break;
  case: 'mostly full':
console.log('Arms and legs are getting hairier');
break;
  case: 'mostly new':
console.log('Back on two feet');
break;
  default:
console.log('Invalid moon phase');
break;}

I believe there is either some error with the introductory material or I am make an error that I can’t identify. I am erring on the side that it may be my fault, which is decreasing my confidence to go on with the other material. I am sure I am not the only person experiencing this problem.

I don’t know if I categorized it under the right topic so feel free to correct me. I am hoping to sound open to criticism


#2

please include the exercise url and your error message

here:

switch (groceryitem) 

why use groceryitem? Where is this variable coming from?


#3

[Werewolf-example

Im editing it right now. It is still marking it wrong despite that.


#4

I have edited the link. Please help me when possible.


#5

running your new code, it produces an error:

/home/ccuser/workspace/learn-javascript-U2L1E5-8/main.js:5
  case: 'mostly full':
      ^

this clearly indicates that there is a syntax problem with your code? Do you see it?

Good you fixed the variable on which the statement is executed


#6

switch statement blocking…

switch (expression) {
case match_expression:
  // code statements
  break;
case ____:
  // code statements
  break;
default:
  // code statements
}

#7

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