← Back to challenges

Calculating Damage

JavaScriptHardmathconditions

Instructions

Create a function that takes damage and speed (attacks per second) and returns the amount of damage after a given time.

Examples

damage(40, 5, "second") ➞ 200

damage(100, 1, "minute") ➞ 6000

damage(2, 100, "hour") ➞ 720000

Notes

Return "invalid" if damage or speed is negative.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Free Coffee Cups