New to js/html so help is needed.
i have this simple html file:
<html>
<script type="text/javascript" src="rps.js">
var numOfRounds = 25;
var result = startGame(numOfRounds,player1,player2 );
document.write(result.p1+":"+result.p2);
</script>
</html>
and as you can see the function im calling to is startGame(…)
this is the function:
function startGame(rounds, player1, player2) {
var counter = 0;
while (counter < rounds) {
player1.itemChosen = player1.play();
player2.itemChosen = player2.play();
player1.feedback(player2.itemChosen);
player2.feedback(player1.itemChosen);
counter++;
}
return {p1: player1.getW(),p2: player2.getW() }
};
but for some reason when i try to debug it (chrome) the startGame function is not
called at all.
any ideas?
You cannot have any code inside a script tag with a src attribute.
Either use a script tag with a src attribute, or a script tag without src attribute and with code inside it, or both.