The OR Operator

EasyAcc. 95.2%
+25 XP 8

Logic Fallback

The Logical OR (||) operator returns the first "truthy" value it encounters. It is widely used for providing default or fallback values.

  1. Use || to return userSetting OR defaultValue.

01EXAMPLE 1

InputuserSetting = null, defaultValue = "Dark Mode"
Output"Dark Mode"

Explanation: null is falsy; falls back to default.

Constraints

  • Use || operator.
  • Be aware that || falls back for 0 and empty strings.
FundamentalsLogicOperators
JavaScript
Loading...
9 Hidden

Input Arguments

userSettingnull
defaultValue"Dark Mode"

Expected Output

Dark Mode

Click RUN to test your solution