Help with codeacamdemy project please

Hi I am attempting the 3 rd project and I have written a switch statemnts but when I try to print them from a console.log() it doesn’t print anything. I have checked the help video and I belie I have done all the same.
Any help would be appreciated…

let userName = ‘Steve’;

userName ? console.log(Hello ${userName}.) : console.log(‘■■■■!o’);

let userQuestion = ‘why are we here’;

console.log(You ${userName}, would like to know, ${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 = ‘Ha ha Fat chance’;

break

case ‘6’:

eightBall = ‘wouldnt bet on it’;

break

case ‘7’:

eightBall = ‘could do’;

break

case’8’:

eightBall = ‘Of course’;

}

console.log(eightBall);

Thanks

Hello @steveforrest1983. Welcome to the forums! Be careful with your case statements. It looks like you are checking strings, but the randomNumber variable is an integer.

1 Like

Where you have put randomNumber = Math.floor(Math.random()*8, this is giving you a random number between 0 and 7, so you do not require case 8, in addition to the issue @codeneutrino gave also.

1 Like

Ok, thank you I understand what your saying in princiaple but how do I correct this? I am even more confused because the solution video with brian does is what Ihave checked through and cant see the difference.
Thank you

What is the data type of randomNumber and what is the data type of '1'?

1 Like

data type of randomNumber is int and im not sure what you mean by data type of 1

randomNumber is of type int. Are '0', '1', etc., of type int?

switch (randomNumber){

case ‘0’:
eightBall = ‘It is certain’;
break

case ‘1’:
...
1 Like

brilliant thank you I feel like an idiot now

No, not an idiot, just overlooked a detail. It seems it’s never the last time for any of us – that’s why the compilers are designed to present us with error messages.