← Back to challenges

Battle Game

JavaScriptHardgamesnumbers

Instructions

You were bored, so you decided to try out a new game you recently downloaded. There are five types of characters, each with their own level of attack power, defense, and speed. There are also five types of armor, weapons, and boots. Each type of item has a different cost of gold and a different level of attack power, defense or speed.

Create a function that takes the type of character and the amount of gold. The function should return the maximum amount of attack power possible, the maximum amount of defense possible, and the maximum speed possible in an array, in that order.

Examples

maxStats("Robot", 160) ➞ [210, 220, 26]

maxStats("Fairy", 50) ➞ [91, 120, 22]

maxStats("Warrior", 70) ➞ [210, 211, 14]

Notes

  • Calculate the attack power, defense, and speed seperately. Do not calculate combinations of items.
  • Hint: Add the character's stats to the items' stats for the result.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.