Bracket Notation
Bracket Notation
Dot notation reads a property whose name is written directly in the code. Bracket notation reads the property named by an expression, so a variable can decide which property is used.
This matters when user choices, form fields, or API data decide which setting to read.
Your task: Use bracket notation to read the value from preferences named by selectedPreference. Store it in preferenceValue, then log it. Avoid reading a literal property called selectedPreference.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
Bracket Notation
Dot notation reads a property whose name is written directly in the code. Bracket notation reads the property named by an expression, so a variable can decide which property is used.
This matters when user choices, form fields, or API data decide which setting to read.
Your task: Use bracket notation to read the value from preferences named by selectedPreference. Store it in preferenceValue, then log it. Avoid reading a literal property called selectedPreference.