Hi everyone, here’s my code for this project
let userName = "Sandy";
userName ? console.log("Hello, ${userName}!") : console.log("Hello!");
let userQuestion = "Will the orchid flower next week?";
console.log("${userName} has asked - ${userQuestion}");
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 = "Signs point to yes";
}
console.log("The Magic Eight Ball says, ${eightBall}");
And the result comes out like this -
Hello, ${userName}!
${userName} has asked - ${userQuestion}
2
The Magic Eight Ball says, ${eightBall}
Can someone go through my codes to see why the name, question and the eightBall phrase aren’t showing?
Many thanks,
S