Logical operators help!


#1



var user = prompt("Are you ready to play?").toUpperCase();
switch (user) {
case 'YES':
var playTime = prompt("Do you like to play choose your own adventure games? Choose "YES" or "NO"");
var restTime = prompt("Do you want to take a break? Choose "YES" or "NO"");
if (playTime === "YES" || restTime === "NO") {
console.log("Then let's play!");
} else {
console.log("Take a little break then!");
}
break;
case 'NO':
var timeToRest = prompt("Are you needing a break? Choose "YES" or "NO"");
var sleep = prompt("Would you like to take a nap? Choose "YES" or "NO"");
if (timeToRest ==="YES" && sleep === "YES") {
console.log ("We will see you later on!");
} else {
console.log ("Take a breather and let's play");
}
break;
case 'NOT SURE':
console.log("Try it out!");
break;
default:
console.log("You have to log an answer");
};

https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661


SyntaxError: missing ) after argument list


Replace this line with your code.


#2

do like this

var playTime = prompt("Do you like to play choose your own adventure games? Choose YES or NO");
var restTime = prompt("Do you want to take a break? Choose YES or NO");

and here

var timeToRest = prompt("Are you needing a break? Choose YES or NO");
var sleep = prompt("Would you like to take a nap? Choose YES or NO");

if you need more space between "yes" or "no" or anything then you should use + operator.


#3

Double quotes in double quotes, or unescaped quotes.

" ... \"YES\" or \"NO\" "    // escape makes them into printing characters

Or, use single quotes inside the string.


#5

Thanks! I got it to complete, but it mixes up my answers. When the || statement should return true, it returns false. Same with the && statement.


#6

Remember that OR (a || b) evaluates to true on any truthy operand. If both conditions must be true then use &&.

I like to play games && I am not tired.