25% off

Use code FUNCMAIN at checkout for 25% off all premium courses.

Get started โ†’

Interactive Go ยท Lesson

Quest: The Spell Loop

A barrage of blows is incoming, adventurer. This quest brings together the tools of Module 4: a variadic parameter for the unknown number of hits, a loop to apply them, and multiple return values to report the outcome.

Your Quest

Complete applyDamage: subtract every value in hits from health, then return the remaining health and a boolean for whether it’s still above 0.

With applyDamage(100, 30, 40, 20) the hits total 90, so:

10 true

Hint

for _, h := range hits { health -= h }, then return health, health > 0.

Additional Scrolls of Wisdom