Hey if someone could Debug my code please!


#1

Hey I wrote a code and debugged it the best I could but I'm still getting errors if someone could finish debugging it it would be appreciated thanks!

var user = prompt("How do you do you do?").toUpperCase();
switch(user) {
case 'GOOD':
console.log("Is there something wrong? why not great? I'm Mr Lincon your guide");
var whatsWrong = prompt("What's Wrong?").toUpperCase();
if (whatsWrong = NOTHING || LEAVE ME ALONE) {
console.log("Okay Then...");
}
else
{
console.log("It'll be okay...");
}
break;
case 'GREAT':
console.log("Great! Lets go. I'm Mr Lincon your guide");
var sunny = true
var day = true
if (sunny && day) {
console.log("It's a beautiful day isnt it?");
}
else if (day && sunny = false) {
console.log("Darnit its raining!");
}
else {
console.log ("Goodnight!");
}
break;
case 'OK':
console.log("What's wrong? I'm Mr Lincon your guide");
var whatsWrong = prompt("What's Wrong?").toUpperCase();
if (whatsWrong = NOTHING || LEAVE ME ALONE) {
console.log("Okay Then...");
}
else
{
console.log("It'll be okay...");
}
break;
case 'TERRIBLE':
console.log("Oh Golly! I dont want to work with someone that down!");
break;
default:
console.log("What? I'm serious how are you feeling?");
}


#2

* You need NOTHING and LEAVE ME ALONE to be in quotation marks; Also, you need to reinterate that you are checking if whatsWrong == "LEAVE ME ALONE"; And finally, a single = is for assigning a variable, == is for checking if they are equal, and === is for checking if they are exactly the same.

** Shortened your code

var user = prompt("How do you do you do?").toUpperCase();
switch (user) {
  case 'GOOD':
    console.log("Is there something wrong? why not great? I'm Mr Lincon your guide");
    var whatsWrong = prompt("What's Wrong?").toUpperCase();
    if (whatsWrong == "NOTHING" || whatsWrong == "LEAVE ME ALONE") { // *
      console.log("Okay Then...");
    } else {
      console.log("It'll be okay...");
    }
    break;
  case 'GREAT':
    console.log("Great! Lets go. I'm Mr Lincon your guide");
    var sunny = true;
    var day = true;
    if (sunny && day) {
      console.log("It's a beautiful day isnt it?");
    } else if (day && !sunny) { // **
      console.log("Darnit its raining!");
    } else {
      console.log("Goodnight!");
    }
    break;
  case 'OK':
    console.log("What's wrong? I'm Mr Lincon your guide");
    var whatsWrong = prompt("What's Wrong?").toUpperCase();
    if (whatsWrong == "NOTHING" || whatsWrong == "LEAVE ME ALONE") { // *
      console.log("Okay Then...");
    } else {
      console.log("It'll be okay...");
    }
    break;
  case 'TERRIBLE':
    console.log("Oh Golly! I dont want to work with someone that down!");
    break;
  default:
    console.log("What? I'm serious how are you feeling?");
}

#3

thanks I really do mess up on things like that sometimes!