I'm struggling with this small code where I want to look thru an array and fetch the nearest level (number) if experience (2nd number) is between 2 levels.
var Levels = [
[1, 0],
[2, 83],
[3, 174],
[4, 276],
[5, 388]
];
var Level = 1;
var Exp = 200;
if(Exp < Levels[1][1])
{
Level = Levels[Level];
}
else {
Level = Levels[Level];
}
So the result I should get here is level 3 since I got 200 exp and that will put me between 3-4.
If anyone can help out, I would greatly appreciate it!