IDK why this isn't working



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:

//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''");
  case 'Earth':
    confirm("You chose the Earth magic type");
  case 'Fire':
    confirm("You chose the Fire magic type");
  case 'Ice':
    confirm("You chose the Ice magic type");
  case 'Lightning':
    confirm("You chose the Lighning magic type");
    confirm("Choose a magic type please!");


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:


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'");
// 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:


That really did solve the problem! Thanks!