Opening your workspace…
Workspace/Coding room
Opening your workspace…
Your next battle can wait until Nurse Joy has finished at the Pokémon Center. Each Pokémon in your party has a pair of integers (currentHP, maxHP), with 0 ≤ currentHP ≤ maxHP. Nurse Joy heals each one to its maximum. Return the total HP she restores. A fainted Pokémon starts at 0 HP, a healthy one needs no healing, and an empty party gives a total of 0.
[12,35,0], [20,50,30]Output53Nurse Joy restores 8 HP, 15 HP, and 30 HP, for a total of 53.
[40,60,25], [40,80,25]Output20The first and third Pokémon are already at full HP. The second needs 20 HP restored.
Add the missing HP for each party member.
function solve(currentHP, maxHP) { // Write your solution here. }
Tab inserts two spaces. Shift+Tab outdents. Use the arrow keys and Tab to choose a suggestion. Press Escape, then Tab, to leave the editor. Press Control or Command with apostrophe to run samples or with Enter to submit.