Final Project alert and prompt malfunction


#1

https://www.codecademy.com/final_project/javascript


When I run the program, and it is properly linked to an html program/file, the alerts and prompts don't show up. What am I doing wrong? No error messages appear just nothing happens.


hiveEnemy.randomSpawn = function(){
	var randomNum = Math.floor((Math.random() * 3) + 1);
	if(randomNum === 1){
		alert("Oh my gosh the tower, it's infested with hive large knights!");
	} else if (randomNum === 2){
		alert("The thrall have accumulated in the North wing of the tower, we can do this!");
    } else{
		alert("The acolytes are snipers, we have to get rid of them quickly or the Tower will fall!");
	}
};


function questionOne(){
    var userInput = prompt("Listen Gaurdian, we only have three weapons available at this point. The Fatebringer, The Mida Multitool, and the Zhalo Supercell. Since they're exotic they have precipitous upside and downside. It's truly a weapons gamble. Which one you rollin' with?");
    
    if(userInput.toLowerCase() === autorifle.toLocaleLowerCase()){
        alert("Good choice! the Zhalo has a chance to chain lightning rounds between enemies. But with such rapid fire beware its low stability")
    } else if(userInput.toLowerCase() === handcannon.toLocaleLowerCase()) {
        alert("Awesome, this Fatebringer packs a punch and a headshot is a done deal. I would watch out for its slow rate of fire and reload times, otherwise you should be good.")
    } else if(userInput.toLocaleLowerCase() === scoutrifle.toLocaleLowerCase()) {
        alert("The name speaks for itself, increased rate of fire and reload speed, but careful the zoom tends to narrow the point of view...")
    }
}


#2

Personally I have not done this exercise. But in order for functions to work they need to be called.
Do this by calling the function name at the bottom of your code, like this.

questionOne()

#3

hey, I updated my code and it still doesn't seem to work. I call both functions at the end.

var hiveEnemy = function {
var randomNum = Math.floor((Math.random() * 3) + 1);
if (randomNum === 1) {
alert("Oh my gosh the tower, it's infested with hive large knights!");
} else if (randomNum === 2){
alert("The thrall have accumulated in the North wing of the tower, we can do this!");
} else{
alert("The acolytes are snipers, we have to get rid of them quickly or the Tower will fall!");
}
};
}
hiveEnemy();

function questionOne(){
var userInput = prompt("Listen Gaurdian, we only have three weapons available at this point. The Fatebringer, The Mida Multitool, and the Zhalo Supercell. Since they're exotic they have precipitous upside and downside. It's truly a weapons gamble. Which one you rollin' with?");

if(userInput.toLowerCase() === autorifle.toLocaleLowerCase()){
    alert("Good choice! the Zhalo has a chance to chain lightning rounds between enemies. But with such rapid fire beware its low stability")
} else if(userInput.toLowerCase() === handcannon.toLocaleLowerCase()) {
    alert("Awesome, this Fatebringer packs a punch and a headshot is a done deal. I would watch out for its slow rate of fire and reload times, otherwise you should be good.")
} else if(userInput.toLocaleLowerCase() === scoutrifle.toLocaleLowerCase()) {
    alert("The name speaks for itself, increased rate of fire and reload speed, but careful the zoom tends to narrow the point of view...")
}

}
questionOne()