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
- Effectively construct
||specifically betweenuserSettingexactly OR locallydefaultValue. - Immediately yield out your discovery safely.
01EXAMPLE 1
Input
userSetting = 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
JavaScriptSystem handles I/O — write your function only
Loading...
5 Hidden
Input Arguments
userSettingnull
defaultValue"Light"
Expected Output
Light
Click RUN to test your solution