Random Number and (eightBall), doesn't output the case value response. (conditionals) Please help I'm a noob

Hello. I was just trying to working on a eight ball project and felt I finished it but never got it to work properly. Random number is generated through .math which is 1 or 2 an then multiplied by 8? When I’d think it be a maximum of 8. Then the empty eightBall be givin the random number that was generated which is then switched through the values which have a corresponding string value which is then displayed with console log. Only the string values for the valued numbers doesn’t show at the end of the code it seams.

I just want to know why it doesnt show anything for the new eightball value. it shows the random number. Please can someone help I am new and this is one of my first projects with a lot to take in.

I would really appreciate it.


let randomNumber = Math.floor(Math.random() * 8);
console.log(`${randomNumber}`);
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 = 'It is certain';
    break;          
}

console.log(`The computer predicts 
${eightBall} `); 
console.log(eightBall);

//the code outputs

Hello Tom
Tom has asked: Can you answer the quesiton? 
4
The computer predicts 



The code outputs

Hi welcome to forums :slight_smile:

Can you retry posting your code, press the format button once </> and paste all your code (formatted) inside it. It’ll make it much easier to troublesshot.

Thanks for the welcome, please see the edited op.

The camel-casing is inconsistent, the code should work otherwise!

let eightBall = '';
eightball = 'It is certain';
console.log(`The computer predicts 
${eightBall} `);
1 Like

:smiley: :smiley: :smiley:

Thank you sir. You’ve saved me. I would of never of suspected! How interesting my eyes missed that. And when I fixed it the eightball literually has just returned " The computer predicts
Outlook not so good
Outlook not so good"

:smiley: Have a nice night thanks again.

1 Like