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