1.9 KiB
1.9 KiB
id, title, challengeType, forumTopicId, localeTitle
| id | title | challengeType | forumTopicId | localeTitle |
|---|---|---|---|---|
| 587d7dac367417b2b2512b74 | Use Dot Notation to Access the Properties of an Object | 1 | 301333 | Использовать точную нотацию для доступа к свойствам объекта |
Description
object с различными properties , теперь вы увидите, как получить доступ к значениям этих properties . Вот пример: let duck = {Точечная нотация используется для имени
имя: «Афлак»,
numLegs: 2
};
console.log (duck.name);
// Это печатает «Aflac» на консоли
object , duck , а затем имя property , name , для доступа к значению «Aflac».
Instructions
properties объекта dog ниже на консоль.
Tests
tests:
- text: Your code should use <code>console.log</code> to print the value for the <code>name</code> property of the <code>dog</code> object.
testString: assert(/console.log\(.*dog\.name.*\)/g.test(code));
- text: Your code should use <code>console.log</code> to print the value for the <code>numLegs</code> property of the <code>dog</code> object.
testString: assert(/console.log\(.*dog\.numLegs.*\)/g.test(code));
Challenge Seed
let dog = {
name: "Spot",
numLegs: 4
};
// Add your code below this line
Solution
let dog = {
name: "Spot",
numLegs: 4
};
console.log(dog.name);
console.log(dog.numLegs);