JSFiddle - React, Tailwind, and code Playground

by Cameron Bernhardt

JavaScript

//VARIABLES
    var dmgMultiply;
    var dmg = 10;
    var armour = 0;
    var hp = 100;

    //ENEMY VARIABLES
    var dmgGoblin;
    var goblinHP = 100;

    //ARRAYS
    var choiceArray = ["Type 'sword' equip your sword.", 
                       "Type 'run' if you're scared.",
                       "Type 'stats' to see your stats."];
    var answerArray = ["sword", "run", "stats"];
    var outcomeArrayOne = ["You equip your sword.", 
                           "You run away. Game Over."];            
    var outcomeArrayTwo = ["Sword Equipped."]

    //GAME CHOICE
    function choice(a, b, c, x, y, z, aa, bb)
    {
         var answer = prompt(a + "\n" + b + "\n" + c);

         if(answer == x)
         {
              alert(aa);
              swordEquipped(outcomeArrayTwo[0]);
         }

         if(answer == y)
         {
              alert(bb);
         }

         if(answer == z)
         {
              displayStats();   
         }
    }

    //EQUIPPED SWORD
    function swordEquipped(a)
    {
        dmg = 25;
        dmgMultiply = Math.floor(Math.random() * 25 + 1);
        alert(a + "\n" + "DMG : " + dmg);
        goblinCombatStart("goblin");
    }

    //GOBLIN COMBAT START
    function goblinCombatStart(g)
    {
        alert("A wild " + g + " appears!" + "\n" + "The " + g + " has 100 HP!");
        goblinAttack("goblin")
    }

    function goblinAttack(g)
    {
        dmgMultiply = Math.floor(Math.random() * 10 + 1);
        dmgGoblin = Math.floor(Math.random() * 10 + 1);
        alert("The " + g + " swings his axe at you!" + "\n"  + "The " + g + " does " + dmgGoblin + " damage to you!");
        hp -= dmgGoblin;
        var attack = prompt("Type 'attack' to swing your sword at the " + g + "\n" + "HP : " + hp);

        if(attack == "attack")
        {
            alert("You swing your sword at the " + g + "\n" + "You did " + dmgMultiply + " to the " + g);
            goblinHP -= dmgMultiply;
            alert("The " + g + " is on " +...