I'm attempting to refactor my code to use anonymous closures as I want to make some of the methods private. I've never done this before and nothing I try seems to work. My tests are failing saying: "player.bowl is not a function in file"
var Player = function (name) {
var username = name;
this.getName = function () {
return username;
};
var bowl = (function (frame) {
var hitPins, knockDownPins;
return {
knockDownPins: function () {
hitPins = Math.floor(Math.random()*(frame.pins+1));
frame.pinsStanding(hitPins);
frame.bowlsHadThisFrame += 1;
return hitPins;
}
};
})();
}
What have I done wrong? Also are there any good online resources where I can find out more about anonymous functions? :)