Codecademy Forums

Help with Magic Eightball Control Flows

I thought I was a good job following this until the very end. For some reason on step 8 my code doesn’t generate an eight ball response. The output always just reads "The eight ball says: ". There is always just a blank space at the end.

I tried rewriting everything and followed the instructional video and still can not fix the issue. Does anyone know what I might be doing wrong?

https://www.codecademy.com/courses/introduction-to-javascript/projects/magic-eight-ball-1?action=resume_content_item

My code:

let userName = 'James'

userName ? console.log(`Hello, ${userName}!`):
console.log('Hello!');

let userQuestion = 'Should I eat dinner?'

console.log(`${userName} asked ${userQuestion}`);

let randomNumber = Math.floor(Math.random() * 8);

let eightBall = ''

switch(randomNumber) {
  case 0:
    eightball = 'It is certain';
    break;
  case 1:
    eightball = 'It is decidedly so';
    break;
  case 2:
    eightball = 'Reply hazy try again';
    break;
  case 3:
    eightball = 'Cannot predict now';
    break;
  case 4:
    eightball = 'Do not count on it';
    break;
  case 5:
    eightball = 'My sources say no';
    break;
  case 6:
    eightball = 'Outlook not so good';
    break;
  case 7:
    eightball = 'Signs point to yes';
    break;
}

console.log(`The eight ball says: ${eightBall}`);

Look how you spelled eightBall in your switch block.

1 Like