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.

  1. Return userScore if it is not null/undefined, otherwise return startScore.

01EXAMPLE 1

InputuserScore = 0, startScore = 50
Output0

Explanation: 0 is preserved as a valid score.

Constraints

  • Use ?? operator.
  • Compare behavior with ||.
FundamentalsLogicOperators
JavaScript
Loading...
9 Hidden

Input Arguments

userScore0
startScore50

Expected Output

0

Click RUN to test your solution