Last active
April 10, 2020 12:49
-
-
Save Waltari10/8aab7241b5f0df580490859fbc564d25 to your computer and use it in GitHub Desktop.
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
const heroLevelArr = [ | |
2, | |
4, | |
6, | |
8, | |
11, | |
14, | |
17, | |
20, | |
24, | |
28, | |
32, | |
36, | |
41, | |
46, | |
51, | |
56, | |
62, | |
69, | |
76, | |
83, | |
90, | |
]; | |
export const getHeroLevel = (exp = 0) => { | |
let level = 1; | |
if (!parseInt(exp) || isNaN(parseInt(exp))) { | |
return level; | |
} | |
heroLevelArr.forEach((threshold, index) => { | |
if (exp >= threshold) { | |
level = index + 1; | |
} | |
}); | |
return level; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment