Nullish Coalescing
EasyAcc. 92.7%
+30 XP 10
Selective Fallbacks
Modern systems use the Nullish Coalescing (??) operator when they want to preserve 0 or false as valid inputs, only falling back if the value is strictly null or undefined.
- Return
userScoreif it is not null/undefined, otherwise returnstartScore.
01EXAMPLE 1
Input
userScore = 0, startScore = 50Output
0Explanation: 0 is preserved as a valid score.
Constraints
- Use ?? operator.
- Compare behavior with ||.
FundamentalsLogicOperators
JavaScriptSystem handles I/O — write your function only
Loading...
9 Hidden
Input Arguments
userScore0
startScore50
Expected Output
0
Click RUN to test your solution