--- id: 56533eb9ac21ba0edf2244c7 title: Accessing Object Properties with Dot Notation challengeType: 1 videoUrl: '' localeTitle: Acceso a las propiedades del objeto con notación de puntos --- ## Description
Hay dos formas de acceder a las propiedades de un objeto: notación de puntos ( . ) Y notación de corchetes ( [] ), similar a una matriz. La notación de puntos es lo que usa cuando conoce el nombre de la propiedad a la que intenta acceder con anticipación. Aquí hay una muestra del uso de la notación de puntos ( . ) Para leer la propiedad de un objeto:
var myObj = {
prop1: "val1",
prop2: "val2"
};
var prop1val = myObj.prop1; // val1
var prop2val = myObj.prop2; // val2
## Instructions
Lea los valores de propiedad de testObj usando la notación de puntos. Establezca la variable hatValue igual al hat propiedad del objeto y establezca la variable shirtValue igual a la shirt propiedad del objeto.
## Tests
```yml tests: - text: hatValue debe ser una cadena testString: 'assert(typeof hatValue === "string" , "hatValue should be a string");' - text: El valor de hatValue debe ser "ballcap" testString: 'assert(hatValue === "ballcap" , "The value of hatValue should be "ballcap"");' - text: shirtValue debe ser una cadena testString: 'assert(typeof shirtValue === "string" , "shirtValue should be a string");' - text: El valor de shirtValue debe ser "jersey" testString: 'assert(shirtValue === "jersey" , "The value of shirtValue should be "jersey"");' - text: Deberías usar la notación de puntos dos veces. testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");' ```
## Challenge Seed
```js // Setup var testObj = { "hat": "ballcap", "shirt": "jersey", "shoes": "cleats" }; // Only change code below this line var hatValue = testObj; // Change this line var shirtValue = testObj; // Change this line ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```