Magic Eightball project

Hey so i’ve been messing with this for a bit now and can’t figure it out. Its constantly logging:
“Hello, ‘Name’!”
“‘Name’ asked: ‘Question’.”
“Signs point to yes”

Idk why it’s always saying signs point to yes and why it isn’t cycling through the randomNumbers… Help would be greatly appreciated

//One can add their name inbetween the quotation marks, or be known as a stranger.
var userName = 'Ed';

//Ternary code to see if someone has put their name inbetween the quotation marks above.
userName ? console.log(`Hello, ${userName}!`) : console.log('Hello, stranger!')

//Type your question inbetween the quotes bellow.
var userQuestion = 'Am I alive?';

//Will print out question on the console
console.log(`${userName} asked:` + ' ' + userQuestion);

//Creates a random number 0-7
let randomNumber = Math.floor(Math.random() * 8);

let eightBall = '';

if (randomNumber === 0) {
  eightBall=('It is certain');
} else if (randomNumber === 1) {
  eightBall=('It is decidedly so');
} else if (randomNumber === 2) {
  eightBall=('Reply hazy try again');
} else if (randomNumber === 3) {
  eightBall=('Cannot predict now');
} else if (randomNumber === 4) {
  eightBall=('Do not count on it');
} else if (randomNumber === 5) {
  eightBall=('My sources say no');
} else if (randomNumber === 6) {
  eightBall=('Outlook not so good');
} else if (randomNumber === 7); {
  eightBall=('Signs point to yes'); 
} 

console.log(eightBall);


Ok so i fixed it and this is my code now. Yet can someone explain how it works now? I’m lost

//One can add their name inbetween the quotation marks, or be known as a stranger.
var userName = 'Ed';

//Ternary code to see if someone has put their name inbetween the quotation marks above.
userName ? console.log(`Hello, ${userName}!`) : console.log('Hello, stranger!')

//Type your question inbetween the quotes bellow.
var userQuestion = 'Am I alive?';

//Will print out question on the console
console.log(`${userName} asked:` + ' ' + userQuestion);

//Creates a random number 0-7
var randomNumber = Math.floor(Math.random() * 8);

let eightBall = ('');

if (randomNumber === 0) {
  eightBall=('It is certain');
} else if (randomNumber === 1) {
  eightBall=('It is decidedly so');
} else if (randomNumber === 2) {
  eightBall=('Reply hazy try again');
} else if (randomNumber === 3) {
  eightBall=('Cannot predict now');
} else if (randomNumber === 4) {
  eightBall=('Do not count on it');
} else if (randomNumber === 5) {
  eightBall=('My sources say no');
} else if (randomNumber === 6) {
  eightBall=('Outlook not so good');
} else if (randomNumber === 7); {
  eightBall==('Signs point to yes'); 
} 


console.log(eightBall);


You have a ; that does not belong there.

1 Like

It’s still not working completely right eightBall==('signs point to yes ') is stopping the last response from working properly.
Remove one of the = signs.

1 Like

Are the semicolons only supposed to be there like commas in a list of things? eg. apples, oranges, potato’s // and not apples, oranges, potato’s, … Yet in the sense of else…if statements?

Edit: I see the extra semicolon now… ignore this question