Javascript - else if chains
Code Life
By Pierre Marsaa
More Than Two Choices
if/else gives you two paths. But what if there are three, four, five possibilities? A Codémon can be in great shape, tired, or knocked out. That's what else if is for.
↗️
Loading editor...
↶
↷
With 45 HP: the first condition is false, the second is true, so "tired" is printed. Try 90 and 10 to see the other branches!
As Many as You Need
You can chain as many else if as you want between the first if and the final else. The final else is optional.
Verify