I am learning java script for my OU course and have hit brickwall.
Can any kind fold help me please?
I am trying to write a function for this statement:
*switches current player
*
*function takes no argument
* if current player is 1, sets current player to 2
* otherwise sets current player to 1
*function returns no value
So far I have:
code:
function switchCurrentPlayer()
{
if (currentPlayer = 1)
{
currentPlayer = 2;
}
else
{
currentPlayer = 1;
}
}
Using this code to test I keep getting player 2
code:
switchCurrentPlayer();
document.write('player ' + currentPlayer + '<br>');
switchCurrentPlayer();
document.write('player ' + currentPlayer + '<br>');
Anyone point me in the right direction? I am going a bit screen blind.