Computed properties in JavaScript

When declaring an object, the names of its properties can be taken from variables. Such properties are called computed. Let's see how it's done. Let's have the following object:

javascriptlet obj = {
  a: 1,
  b: 2,
  c: 3
};

Let the name of some property be stored in a variable:

javascriptlet key = 'a';

Let's make it such a way that instead of the property name, the value from our variable is taken. To do this, the variable should be enclosed in square brackets:

javascriptlet obj = {
  [key]: 1,
  b: 2,
  c: 3
};

When declaring computed properties, you can execute some code. An example:

javascriptlet obj = {
  [key + '1']: 1,
  [key + '2']: 2,
  [key + '3']: 3
};
Задание 1

In the following code, the key should have been taken from a variable. Fix the mistake you made:

javascriptlet key = 'x';

let obj = {
  key: 1,
  y: 2,
  z: 3
};
Задание 2

Given an object:

javascriptlet obj = {
  x: 1,
  y: 2,
  z: 3
};

Given variables:

javascriptlet key1 = 'x';
let key2 = 'y';
let key3 = 'z';

Make the object keys to be taken from these variables.