Skip to content

Instantly share code, notes, and snippets.

@mahmoud-samy
Created August 28, 2016 14:56
Show Gist options
  • Save mahmoud-samy/06345d762f1eef1c6516b9e72c692a38 to your computer and use it in GitHub Desktop.
Save mahmoud-samy/06345d762f1eef1c6516b9e72c692a38 to your computer and use it in GitHub Desktop.
// Fix the following program to show the correct game name
var userId;
(function initialize(){
function generateUserName(n) {
return (((Math.sin(n) * 1000) - Math.floor((Math.sin(n) * 1000))) * 1000).toFixed(0);
}
var userKey = 2222222222;
userId = name = generateUserName(userKey);
})();
var game = {
name: "JS Game",
numberOfLevels: 0,
initialize: function(options){
(function(){
if (options.isDemo) {
this.numberOfLevels = 3;
} else {
this.numberOfLevels = 100;
}
}());
},
debug: function() {
(function() {
console.log("game name: "+ this.name);
console.log("number of levels: "+ this.numberOfLevels);
}());
}
};
game.initialize({isDemo: true});
game.debug();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment