The Sky Guard
EasyAcc. 97.8%
+15 XP 5
Two Paths, One Choice
Every story has two sides. In programming, the else block represents the "alternative timeline." If the first condition fails, your code takes the backup path.
The Assignment
Your function receives a boolean parameter named isRaining.
- Build a destiny-decider using
if-else:- If
isRainingis true, protect the user by printing: "Bring an umbrella." - Otherwise (the
elsepath), let them roam free by printing: "Enjoy the sunshine!"
- If
01EXAMPLE 1
Input
isRaining = trueOutput
Logs: "Bring an umbrella."Explanation: Condition is true, so the first block runs.
02EXAMPLE 2
Input
isRaining = falseOutput
Logs: "Enjoy the sunshine!"Explanation: Condition is false, so the else block runs.
Constraints
- Use an if-else statement.
- Log messages must match exactly.
Control FlowConditionalsFundamentals
JavaScriptSystem handles I/O — write your function only
Loading...
4 Hidden
Input Arguments
isRainingtrue
Expected Output
Bring an umbrella.
Click RUN to test your solution