Magic Eight Ball giving me same result


#1

I am wondering what part of this is wrong as the code runs, but I get the same result each time which is 1. I tested this in an if/else if statement as well as using switch/case.

let userName = 'Jane';
let userQuestion = 'Will I be rich?';
let randomNumber = Math.floor(Math.random() * 8); //Math.random returns a value between 0 and 1. Math.floor rounds down to a whole number, 0 is inclusive
let eightBall = ''; //in the hint, it says to use a const, but code will not run if it is
userName ? console.log('Hello, ' + userName + '!') : console.log('Hello!');

console.log(userName + ' asked: ' + userQuestion);

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);

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';
    break;
}

console.log(eightBall);

#2

nevermind, I need a comparison operator ‘===’


#3
let userName = '';
userName === 'Jane!' ?console.log(`hello,  ${userName}`) : console.log('Hello!');
const userQuestion = 'Will I become a werewolf tonight?';
console.log(userQuestion);
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';
} 
else { 
eightBall ='No eightball found!';
}
console.log(`The eight ball answered: ${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';
    break; 
   default:
    console.log('no eigthBall found!')
}
    console.log(`The eight ball answered: ${eightBall}`)
   */