-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from lupomontero/translate_object_keys_challenge
Adds spanish translation for object-keys exercise #267
- Loading branch information
Showing
3 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,48 @@ | ||
--- | ||
JavaScript nos da una manera nativa de listar _todas_ las _llaves_ (_keys_) de | ||
un objeto. Esto puede ser muy útil para iterar sobre las propiedades de un | ||
objeto y manipular sus valores. | ||
|
||
# | ||
Veámos un ejemplo de cómo podríamos listar todas las propiedades de un objeto | ||
usando el método **Object.keys()**: | ||
|
||
--- | ||
```js | ||
const car = { | ||
make: 'Toyota', | ||
model: 'Camry', | ||
year: 2020 | ||
}; | ||
const keys = Object.keys(car); | ||
|
||
console.log(keys); | ||
``` | ||
|
||
El código de arriba imprime una arreglo de _strings_, donde cada _string_ es una | ||
_llave_ (_key_) en el objeto `car` (`['make', 'model', 'year']`). | ||
|
||
## El reto: | ||
|
||
Crea un archivo llamado `object-keys.js`. | ||
|
||
En ese archivo, define una variable llamada `car`: | ||
|
||
```js | ||
const car = { | ||
make: 'Honda', | ||
model: 'Accord', | ||
year: 2020 | ||
}; | ||
``` | ||
|
||
Después define otra variable llamada `keys`: | ||
|
||
```js | ||
const keys = Object.keys(car); | ||
``` | ||
|
||
Usa `console.log()` para imprimir la variable `keys` a la consola. | ||
|
||
Comprueba si tu programa es correcto ejecutando el siguiente comando: | ||
|
||
```bash | ||
javascripting verify object-keys.js | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
--- | ||
|
||
# | ||
# CORRECTO. | ||
|
||
Buen trabajo usando el método Object.keys(). Recuerda usarlo cuando necesites listar las propiedades de un objeto. | ||
|
||
El próximo ejercicio trabajaremos con **funciones**. | ||
|
||
Ejecuta `javascripting` en la consola para seleccionar el siguiente ejercicio. | ||
|
||
--- |