Skip to content

Instantly share code, notes, and snippets.

@gipp
Last active December 16, 2015 22:19
Show Gist options
  • Save gipp/5506051 to your computer and use it in GitHub Desktop.
Save gipp/5506051 to your computer and use it in GitHub Desktop.
CATS. Oh yeah, there are (at least) 3 things wrong with this that make the console.log on line 9 not work.
var Kitten = function(name) {
this.name = name;
var mouseCount;
this.init = function() {
this.stalk(function(count) {
mouseCount = count;
});
console.log('You found a kitten! Congrats! Its name is ' + this.name + ' and it caught ' + mouseCount + ' mice');
};
this.hunt = function(callback) {
// some ajax thing
// executes 'callback' when it's finished
// (we'll fake it - you can assume it's successful)
window.setTimeout(function() {
// will always return a value between 1 and 3
callback(Math.floor(Math.random() * 3) + 1);
}, 1000);
}
this.walkAcrossKeyboard = function() {
return 'xcxcxcxcccccccccccjjjjjjjjjjjjjjjjjjjjjjjjj';
};
this.init();
}
var myKitten = new Kitten('Charmander');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment