Reach Next Level

Description


You are playing an RPG game. Currently your experience points (XP) total is equal to experience. To reach the next level your XP should be at least at threshold. If you kill the monster in front of you, you will gain more experience points in the amount of the reward.

Given values experience, threshold and reward, check if you reach the next level after killing the monster.

Example

  • For experience = 10, threshold = 15, and reward = 5, the output should be reachNextLevel(experience, threshold, reward) = true;
  • For experience = 10, threshold = 15, and reward = 4, the output should be reachNextLevel(experience, threshold, reward) = false.

Input/Output

  • [execution time limit] 4 seconds (js)

  • [input] integer experience

    Guaranteed constraints:
    3 \leq experience \leq 250.

  • [input] integer threshold

    Guaranteed constraints:
    5 \leq threshold \leq 300.

  • [input] integer reward

    Guaranteed constraints:
    2 \leq reward \leq 65.

  • [output] boolen

    • true if you reach the next level, false otherwise.

[JavaScript (ES6)] Syntax Tips

1
2
3
4
5
6
// Prints help message to the console
// Returns a string
function helloWorld(name) {
    console.log("This prints to the console when you Run Tests");
    return "Hello, " + name;
}

Solution


1
2
3
function reachNextLevel(experience, threshold, reward) {
	return threshold <= experience + reward
}