Skip to content

Instantly share code, notes, and snippets.

/* //////////////////////////////////////////////////////
// STRINGS, NUMBERS, VARIABLES AND LOOPS //
//////////////////////////////////////////////////////*/
// 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
@mikintosh
mikintosh / gist:f7dd6041df8f3e3dab38491cccbf6535
Created October 21, 2016 10:21
Returning a function (CodeCombat) / helper
// Your goal is to keep at least one flower alive for 60 seconds.
// set 3 new locations
var LOCATIONS = [
{x: 72, y: 44},
{x: 49, y: 59},
{x: 50, y: 25},
{x: 23, y: 43}
];
// loop through all locations
// build a tower on each of them
@mikintosh
mikintosh / gist:4befef9f223b93c6629898b73decc418
Created October 21, 2016 10:23
Returning an object with functions (CodeCombat)
function summonHero (name, position) {
return {
say: function (sentence) {
alert(sentence);
},
move: function (position) {
console.log('Moving to x=' + position.x + ' and y=' +position.y);
this.pos = position;
},
name: name,