Not Getting the Response I Expected


When I select "girl" after choosing dwarf, it still prints the response for "boy" to the console. Can anyone tell me what I'm missing. Other than that, everything seems to work.

var user = prompt("Choose your race. (Human, Goblin, Dwarf, Elf, or Halfling)").toUpperCase();

    case 'HUMAN':
        console.log("Ah, a boring.")
        var gender = prompt("Are you male or female?").toUpperCase();
        var humanClass = prompt("Choose your class: THIEF, WIZARD, or WARRIOR.").toUpperCase();
        if(gender === 'MALE' && humanClass === 'WARRIOR'){
            console.log("Ah, yes! A strapping young Warrior!")
        else if (gender === 'FEMALE' && humanClass === 'WARRIOR'){
            console.log("What a fierce Warrior, you are!")
        else if( gender == 'MALE' && humanClass === 'THIEF'){
            console.log("You look like quite the rascal, thief!")
        else if( gender == 'FEMALE' && humanClass === 'THIEF'){
            console.log("You are awfully pretty for a thief!")
        else if (gender == 'MALE' && humanClass === 'WIZARD'){
            console.log("Funny, you don't look like Gandalf")
        else if (gender == 'FEMALE' && humanClass === 'WIZARD'){
            console.log("I believe you are technically a  Witch, technically speaking...")
            console.log("Not one to be defined by your gender, I see.")
    case 'GOBLIN':
        console.log("Hmmm I never trust a Goblin.")
    case 'DWARF':
        var dwarf = prompt("Are you a boy dwarf or a girl dwarf? I can never tell the difference!").toUpperCase();
       if(dwarf === 'MALE' || 'BOY'){
           console.log("You look just like Gimli!")
       else if (dwarf === 'FEMALE' || 'GIRL'){
           console.log("Of course, you're a girl Dwarf...")
           console.log("I have a perfectly legitimate reason for asking, you know!")
    case 'ELF':
        console.log("Oh goodie, an Elf. Do you know Legolas?")
        var specialty = prompt("Do you prefer ARCHERY or SORCERY?").toUpperCase();
        if (specialty === 'ARCHERY'){
            console.log("Archery, you must know Legolas!")
        else if (specialty === 'SORCERY'){
            console.log ("Sorcery, hmmm...Are you a good witch or a bad witch?")
            console.log("Did you forget your glasses?")
    case 'Halfling':
        console.log("What's a Halfling doing so far away from the Shire?")
        console.log("You don't read so well, do ya?")


Hi @natefore,

Is this within a switch statement? Only issue within the visible code I see is that there are no semicolons at the end of each console.log, which should break your code. However, if this isn't the issue, I'd ask that you please try posting your full code. Thanks.


Rather than saying or "BOY", and or "GIRL", it should say or dwarf === "BOY", dwarf === "GIRL"

The if condition evaluates two booleans, so each side needs to evaluate to true or false. Though strings are truthy statements, you are saying if true/false OR "BOY/GIRL".
Does this make sense? I'm not great at explaining it, so basically you just need to make sure your testing for variable being equal to a string on both sides of the evaluator. :slight_smile:



else if is valid in JavaScript, while elif is valid for Python.


Ahh sorry. I have been python lately so I guess I let it slip through the crack xD


I know that feeling! It's so hard to go between so many similar OOP like Python, JS, Java, and Ruby.


Well and I will answer mutliple coding languages (hopefully) in a day so I know what I am talking about I just forget which one I am doing for a minute xD But yeah it is.


I updated it with my full code, I didn't realize I needed to add ";" after all my console.log(s). Thanks


Yep. That solved it?


It didn't solve my issue, but I appreciate the feedback. I wasn't sure if I needed the semi-colons or not. Everything seems to work when I select Human or Elf but Dwarf prints "You look just like Gimili!" no matter what I enter.


Okay, it took me a minute but I get what you are saying now. This solved my issue, thanks a lot!


Awesome! Sorry it took you a while, I know I'm not the best at explaining things haha. :slight_smile: I'm glad it solved your problem, I was starting to second guess myself.


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