Creating Javascript objects two
How to solve it
Here, we have to create an object that has a different property key in all three test cases. That means we have to dynamically define the object key. This is possible using the bracket notion (compare with this challenge to see how you can access a property value using the bracket notation).
The following example creates a new object that has one property. The key of the property equals the string value of the variable a. We define it using the bracket notation:
const a = 'x';
const object = { [a]: 1 };
console.log(object)
// output: { x: 1 };