// is how you comment
Var – creates new variables
Var fight = function {
Window.alert(“hello world”)
}
Anything with – is a function
Console.log ( playerName + “attacked” + enemyname + “ . “
If else statement
Var playerhealth = 10;
If (playerhealth === 0) {
Console.log(“this wil not run”)
}
Else {
Console.log(“this will run”)
}
Var Boolean = true;
Var booleanf = false;
If (booleanf true) {
Console.log(“the statement is true”);
}
Stop the function by commenting it out
Creating a Array -Var enemyarray = [ 0, 1, 2]; Var enemyarray = [ “tre”, “tony”, “rician”];
Write out enemy names Console.log(enemynames[0];
For loop
For (var I = 0; I < 3; i++) {
Console.log(“apple”);
}
Break; allows you to get out of current loop
The && is the and loop and enables us to set a second condition
While (enemyhealth > 0 && playerhealth > ); {
Console.log(“the player dies”);
}
Two types of screen input
If (playerhealth > 0) {
Window.alert(“you died”);
}
If (playerhealth > 0) {
Console.log(“you died”);
}
Startgame – initializes game
Endgame – finishes the game
If a variable is made outside a function it can be used globally, if a variable is only created in a function it cannot use it outside that function
3.3