Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Computed Property Key

Data Structures, Operators & Stringsmedium

Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 111: The Spread Operator (...)

Implement `makeEntry(key, value)` returning an object with a single computed property `key` set to `value`.

Sample tests

Input: makeEntry("color", "red")
Output: {"color":"red"}
Input: makeEntry("x", 1)
Output: {"x":1}

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Writing { key: value } creates a literal 'key' property, not a dynamic one.

Learning resources

  • MDN: Destructuring assignment
Approach & explanation (try first)

Brackets around key evaluate it, so the property name is dynamic.

Loading...
⌘/Ctrl + Enter

Run your code to see results.