The Void Scanner
MediumAcc. 91.4%
+20 XP 8
Identifying the Void
In JavaScript, not all "falsy" values are the same. A null is different from an undefined, and both are different from a numeric 0. To catch these accurately, you must use Strict Equality (===) within your decision paths.
The Assignment
Your function receives a parameter named val.
- Write a precise
if-else ifladder:- If
valis strictly null, print: "Value is Null." - If
valis strictly undefined, print: "Value is Undefined." - If
valis strictly 0, print: "Value is Zero." - For any other value, print: "Value exists."
- If
01EXAMPLE 1
Input
val = nullOutput
Logs: "Value is Null."Explanation: Strictly matches null.
02EXAMPLE 2
Input
val = 5Output
Logs: "Value exists."Explanation: Matches none of the special falsy cases.
Constraints
- Use strict equality (===).
- Log messages must match exactly including the period.
Control FlowConditionalsTypes
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
valnull
Expected Output
Value is Null.
Click RUN to test your solution