Skip to content

Instantly share code, notes, and snippets.

@flixi
Created May 8, 2016 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flixi/b098d51b887adb21b66de6ea77b66d02 to your computer and use it in GitHub Desktop.
Save flixi/b098d51b887adb21b66de6ea77b66d02 to your computer and use it in GitHub Desktop.
// 1.Single-line comments start with two slashes
/*Multiline comments start with slash-star, and end with star-slash */
//2. JavaScript has a number type
this.say(3);
and a string type
this.say("Joshua");
//3.Strings are created with ' or "
'Kratt';
"Hello, enemy! ";
//4.Strings are concatenated with +
"Attack" + "the" + "enemy!"; //= "Attacktheenemy!"
"Attack " + "the " + "enemy!"; //= "Attack the enemy!"
//5. We can create variables and reuse them
var enemy = hero.findNearestEnemy();
this.attack(enemy);
this.attack(enemy);
//6. If the code repeats - we can use loops
// As does while
while(true) {
this.moveRight();
this.moveUp();
this.moveLeft();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment