i have this function.
function calculateLevel(experience) {
console.log(Math.floor(25 + Math.sqrt(650 + 170 * experience)) / 50);
}
calculateLevel(20);
But, i want to know the reverse of this, example from level 1 get xp amount.
Example if i have level 1.76, in reverse i got 20 xp for this level.
>Solution :
You would do it in reverse:
function calcXP(level) {
console.log(Math.ceil((((level * 50 - 25) ** 2) - 650) / 170));
}
calcXP(1.76) // 20
Just like in math, you would do each operation in reverse, first multiplying by 50, then subtracting 25, then squaring and subtracting 650 and dividing by 170.