else-if Ladder
Tests several conditions in order; the first true one wins.
Beginner
if (v < 1.0) grade = 'L'; else if (v < 2.5) grade = 'M'; else grade = 'H';
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.