freeCodeCamp/curriculum/challenges/russian/02-javascript-algorithms-an.../basic-javascript/accessing-nested-objects.ru...

2.4 KiB
Raw Blame History

id title challengeType guideUrl videoUrl localeTitle
56533eb9ac21ba0edf2244cc Accessing Nested Objects 1 https://russian.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json Доступ к вложенным объектам

Description

Доступ к дополнительным свойствам объектов можно получить, объединив нотацию точки или скобки. Вот вложенный объект:
var ourStorage = {
"стол письменный": {
«ящик»: «степлер»
},
«кабинет»: {
"верхний ящик": {
«folder1»: «файл»,
"folder2": "секреты"
},
«нижний ящик»: «сода»
}
};
ourStorage.cabinet ["верхний ящик"]. folder2; // "секреты"
ourStorage.desk.drawer; // "степлер"

Instructions

Войдите в объект myStorage и назначьте содержимое свойства glove box переменной gloveBoxContents . Используйте обозначения в виде скобок для свойств с пробелом в их имени.

Tests

tests:
  - text: <code>gloveBoxContents</code> должен равняться &quot;картам&quot;
    testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
  - text: Используйте обозначения точек и скобок для доступа к <code>myStorage</code>
    testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'

Challenge Seed

// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

var gloveBoxContents = undefined; // Change this line

After Test

console.info('after the test');

Solution

// solution required