140
rated 0 times
[
147]
[
7]
/ answers: 1 / hits: 65434
/ 11 Years ago, sat, march 16, 2013, 12:00:00
I'm learning javascript and I decided to create simple Rock, Paper, Scissors game. I want to make it controllable by buttons. So I made this in html:
<div id=game>
<button onClick=user(rock)>Rock</button>
<button onClick=user(paper)>Paper</button>
<button onClick=user(scissors)>Scissors</button>
<div id=result></div>
<br>
<br>
<button onClick=test()>DEBUG</button>
</div>
and this in .js file.
var user = none;
function user(choice){
var user = choice;
}
function test(click){
alert(You chose + user);
}
So I thought that after I click Rock button it will change var user to rock but it doesn't. After I click rock and then Debug button I get You chose none.
More From » html