The Dynamic Gate

Medium+20 XP

Mission Briefing

The Chamber of Secrets changes its password mechanism daily! Today, the required access key is hidden inside an encrypted variable. You cannot hardcode dot notation here!

The Concept: Dynamic Keys / Bracket Notation

When the exact property name you want is stored inside a variable, dot notation (obj.key) will literally look for a property named "key"! To evaluate the variable dynamically, you must use bracket notation: obj[variable].

The Objective

Your function receives an object obj and a string variable key.

  1. Use bracket notation to look up the property in obj defined by key.
  2. Return that specific value.

01EXAMPLE 1

Inputobj = { power: 9000 }, key = "power"
Output9000

Constraints

  • You must use bracket notation obj[key].
FundamentalsObjects
JavaScript
Loading...
3 Hidden

Input Arguments

obj{"name":"JS"}
key"name"

Expected Output

JS

Click RUN to test your solution