Well this is embarrasing (5.Logical Operators)


#1


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


var user = prompt("Nice ta meet ya! You've been drafted to fight..something. Some folk say its a wyvern. Whether you believe those rumors or not if your choice. Anyways what are you most skilled in? Swords, Bow and Arrows, or Magyks?");
 
 switch(user) {
     
    case 'Swords':
        console.log("Ya prefer it up close and personal eh? I like ya! Anyways head up to the Town Square and get a Enchantyed sword and shield.");
        break;
    case 'Bow and Arrows':
        console.log("I hope ya have a good shot chap! Now go to the Town Square and get an Enchantyed bow with some arrows!");
        break;
    case 'Magyk':
        console.log("A bit of Hocus Pocus, eh? Head upto the Town Square and get an Enchantyed Magyk cloak!");
        break;
    default:
        console.log("Whatcha gonna do chap?! run around naked singing the creature to the underworld?! Pick a role now!");
 }
switch(user) {

    case 0:

        if(day == 1) {
            console.log("Happy New Year");
        }
        else {
            console.log("Happy January");
        }

        break;

    /* ... */
}

Okay so its not that I entered something and it was wrong but rather I just don't know what I'm supposed to do. I read the instructions and typed out the hint but I just don't know what I'm supposed to do (Currently feeling like an absolute idiot;-; ) SO can like someone explain this and what I'm supposed to do?


#2

@thecodingpenguin,
The are trying to animate you to use a logical operator
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators

var user=(prompt("are you crazy","bit").toUpperCase());
var oldman=true;
var wheelchair=false;
switch(user)
{
case 'YES':
    if ( oldman && wheelchair)
    {
    }
    else
    {
    }
    break;
case 'NO':
    break;
case 'BIT':
if (oldman || wheelchair)
{
}
else
{
}

    break;
default:
 console.log("unkown");
 break;
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators


#3

Thank you! I'll go try it out in a bit!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.