Help w/ Magic Eightball Control Flows

I entered my code for the Magic 8ball, even followed through the “get help” tutorial step by step or so i thought. Can anyone tell me what I’m doing wrong?

https://www.codecademy.com/paths/web-development/tracks/getting-started-with-javascript/modules/learn-javascript-control-flow/projects/magic-eight-ball-1

also, it doesn’t generate the name entered it just puts $username

My code:

let userName = 'India';
userName ? console.log('Hello, $userName'): console.log('Hello!');
let userQuestion = 'Will I be a Top Chef?';
console.log( `India asked : ${userQuestion}`)
let randomNumber = Math.floor(Math.random() * 7);
let eightBall = '';

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

compare how you have used template literals on line 2 vs line 4. there’s inconsistency in the way you’re using them. see if you can spot the bug there. clue is in your own code :wink:

review the last line of your code. you have a bug there.

Also bugs in each case statement. randomNumber is a number :slightly_smiling_face:

1 Like

console.log() will take any expression, including a ternary…

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