Hi,
I just completed the magic eight ball project on the full stack developer course. I used a switch statement to randomise the answers. My issue is that when I run the code, sometimes it will randomly print an empty string, which is not ideal. Is there anything I can do to be able to ignore the empty string when printing to the console? My code is attached below.
let userName = 'Steve';
userName ? console.log(`Hello ${userName}`) :
console.log('Hello');
let userQuestion = 'will I become a warewolf tonight';
console.log(`${userName} wants 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 = 'My sources say no';
break;
case 6:
eighBall = 'Outlook not so good';
break;
case 7:
eightBall = 'Signs point to yes';
break;
}
console.log(eightBall);