简体   繁体   中英

Upon Clicking a Button In My Rock, Paper, Scissors, Shoot Game, I recieve an error claiming the function is not defined, but it is

For some reason, the html code does not show up when I paste it, So I will provide a pastebin link. When I click any of the 3 buttons, I get an error stating that the function is not defined. I am new to java script and have spent and have spent about an hour of googling and debugging, yet it still doesn't work. The game asks what mode you would like, then chooses if it lets you win, lose, or randomizes it. It should then execute a set of logic tests to see who won. This is when it gives an error saying the variable PlayerGameImput is undefined. Thanks in advance for the help, Justin

Pastebin Link: http://pastebin.com/ACR5zpd3

PlayerGameInput is a local variable because you are defining it in each function.

You need to put

var PlayerGameInput;

outside the functions then

PlayerGameInput = "Rock";

Inside the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM