Selecting Defaults

EasyAcc. 95.2%
+25 XP 8

Setting Alternatives

Often website options securely require making alternative choices whenever native data goes completely empty. Generating logical chains through the Logical OR (||) symbol simply forces code directly toward discovering whatever truthy element loads quickest.

The Assignment

  1. Effectively construct || specifically between userSetting exactly OR locally defaultValue.
  2. Immediately yield out your discovery safely.

01EXAMPLE 1

InputuserSetting = null, defaultValue = "Light"
Output"Light"

Explanation: Because null appears totally falsy, it automatically grabs fallback value.

Constraints

  • Provide logic solely driven past || operator.
  • Realize it completely fails whenever values strictly hit zeros.
FundamentalsLogicOperators
JavaScript
Loading...
5 Hidden

Input Arguments

userSettingnull
defaultValue"Light"

Expected Output

Light

Click RUN to test your solution