Hello! I was able to successfully complete this project, but I’m having difficulty comprehending how it is that the console.log(eightBall) gives me the answer from the flow below, if I haven’t explicitly connected the two. Is it just because we left the string empty so it would always go ahead and apply the logic to whichever string was most recently empty?
Could someone shed some light for me? Thanks!
let userName = ‘’;
userName ? console.log(Hello, ${userName}!
)
: console.log(‘Hello!’);
const userQuestion = ‘How are you?’;
console.log(userQuestion);
let randomNumber = Math.floor(Math.random() * 8);
let eightBall = ‘’;
switch (randomNumber) {
case 1:
console.log(‘It is certain’);
break;
case 2:
console.log(‘It is decidedly so.’);
break;
case 3:
console.log(‘Reply hazy try again.’);
break;
case 4:
console.log(‘Cannot predict now.’);
break;
case 5:
console.log(‘Do not count on it.’);
break;
case 6:
console.log(‘My sources say no.’);
break;
case 7:
console.log(‘Outlook not so good.’);
break;
case 8:
console.log(‘Signs point to yes.’);
break;
default:
console.log(‘Try again.’);
break;
}
console.log(randomNumber);
console.log(eightBall);