Last active
December 16, 2015 22:19
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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