IDK why this isn't working

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

I am making a game with my friend, and I keep running across a problem. Whenever I run the code,it asks the question and uses the default switch statement instead of the one it could use. I commented out all of the variables that I am not using yet. Plz help me find out what is wrong :slight_smile:
<In what way does your code behave incorrectly? Include ALL error messages.>

```

//var bag = ;

//var enemyName = [“Fill this in with a name”, “This one too”, “This one”, “and this one”];

//var fiftyPercentChance = Math.floor(Math.randon() * 2 + 1);

//var enemyEncountered = function() {
//prompt(“You encountered a wild” + " " + enemyName + “! Do you ‘‘Run’’, //’‘Fight’’, or check your ‘‘Bag’’?”);
//if (enemyEncountered = “Run”) {
// if (fiftyPercentChance === 2) {
// console.log(“You got away successfully”);
// } else {
// console.log(enemyName + " won’t let you do that");
// }
//} else if (enemyEncountered = “Bag”) {
//if (bag === “”) {
//confirm(“You don’t have any items in your bag!”)
//}
//console.log (“Chat the item you wish to use:” + bag + “!”)
//}
//};

var magicType = function() {
prompt(“Choose your magic: ‘‘Earth’’, ‘‘Fire’’, ‘‘Ice’’, or ‘‘Lighning’’”);
};
magicType();
switch(magicType){
case ‘Earth’:
confirm(“You chose the Earth magic type”);
break;
case ‘Fire’:
confirm(“You chose the Fire magic type”);
break;
case ‘Ice’:
confirm(“You chose the Ice magic type”);
break;
case ‘Lightning’:
confirm(“You chose the Lighning magic type”);
break;
default:
confirm(“Choose a magic type please!”);
break;
}

<do not remove the three backticks above>

you need to store the result of the prompt:

store = prompt("Choose your magic: ''Earth'', ''Fire'', ''Ice'', or ''Lighning''");

and then pass that in the case/switch statement:

switch(store){

magicType is the function, it will never equal a certain string

Hey @ragingamer333 - no need to rage :stuck_out_tongue:

prompt itself is a function. So try it this way:

var magicType = prompt("Choose your magic: 'Earth', 'Fire', 'Ice', or 'Lighning'");
switch(magicType) 
// etc ...

Hope this will help :slight_smile:

removing the function altogether might indeed be a better idea. But that depends on the plans of the user.

True, but I’ll assume that it’s just a simple Input :smile:

1 Like

That really did solve the problem! Thanks!