Skip to content

Instantly share code, notes, and snippets.

@seanbollin
Created February 8, 2014 10:01
Show Gist options
  • Save seanbollin/8881327 to your computer and use it in GitHub Desktop.
Save seanbollin/8881327 to your computer and use it in GitHub Desktop.
Recursive function to calculate XP to level
levelUpExperience: function(level) {
if (!level) { level = this.level + 1; }
if (level === 2) return 100;
return (25 * Math.pow(level, 2)) + this.levelUpExperience(level - 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment