Skip to content

Commit 94c1c13

Browse files
authored
Merge pull request #321 from maksumi/objetos
Objects
2 parents d7bc432 + 0bbfc4a commit 94c1c13

File tree

10 files changed

+197
-199
lines changed

10 files changed

+197
-199
lines changed

1-js/04-object-basics/01-object/2-hello-object/task.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ importance: 5
22

33
---
44

5-
# Hello, object
5+
# Hola, objeto
66

7-
Write the code, one line for each action:
8-
9-
1. Create an empty object `user`.
10-
2. Add the property `name` with the value `John`.
11-
3. Add the property `surname` with the value `Smith`.
12-
4. Change the value of the `name` to `Pete`.
13-
5. Remove the property `name` from the object.
7+
Escribe el código, una línea para cada acción:
148

9+
1. Crea un objeto `user` vacío.
10+
2. Agrega la propiedad `name` con el valor `John`.
11+
3. Agrega la propiedad `surname` con el valor `Smith`.
12+
4. Cambia el valor de `name` a `Pete`.
13+
5. Remueve la propiedad `name` del objeto.

1-js/04-object-basics/01-object/3-is-empty/_js.view/solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function isEmpty(obj) {
22
for (let key in obj) {
3-
// if the loop has started, there is a property
3+
// Si el bucle ha comenzado quiere decir que sí hay al menos una propiedad
44
return false;
55
}
66
return true;

1-js/04-object-basics/01-object/3-is-empty/_js.view/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
describe("isEmpty", function() {
2-
it("returns true for an empty object", function() {
2+
it("retorna true para un objeto vacío", function() {
33
assert.isTrue(isEmpty({}));
44
});
55

6-
it("returns false if a property exists", function() {
6+
it("retorna false si existe una propiedad", function() {
77
assert.isFalse(isEmpty({
88
anything: false
99
}));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Just loop over the object and `return false` immediately if there's at least one property.
1+
Solo crea un bucle sobre el objeto y, si hay al menos una propiedad, devuelve `false` inmediatamente.

1-js/04-object-basics/01-object/3-is-empty/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ importance: 5
22

33
---
44

5-
# Check for emptiness
5+
# Verificar los vacíos
66

7-
Write the function `isEmpty(obj)` which returns `true` if the object has no properties, `false` otherwise.
7+
Escribe la función `isEmpty(obj)` que devuelva el valor `true` si el objeto no tiene propiedades, en caso contrario `false`.
88

9-
Should work like that:
9+
Debería funcionar así:
1010

1111
```js
1212
let schedule = {};
1313

1414
alert( isEmpty(schedule) ); // true
1515

16-
schedule["8:30"] = "get up";
16+
schedule["8:30"] = "Hora de levantarse";
1717

1818
alert( isEmpty(schedule) ); // false
1919
```

1-js/04-object-basics/01-object/5-sum-object/task.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Sum object properties
5+
# Suma de propiedades de un objeto
66

7-
We have an object storing salaries of our team:
7+
Tenemos un objeto que almacena los salarios de nuestro equipo:
88

99
```js
1010
let salaries = {
@@ -14,6 +14,6 @@ let salaries = {
1414
}
1515
```
1616

17-
Write the code to sum all salaries and store in the variable `sum`. Should be `390` in the example above.
17+
Escribe el código para sumar todos los salarios y almacenarl el resultado en la variable `sum`. En el ejemplo de arriba nos debería dar `390`.
1818

19-
If `salaries` is empty, then the result must be `0`.
19+
Si `salaries` está vacio entonces el resultado será `0`.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
let menu = {
22
width: 200,
33
height: 300,
4-
title: "My menu"
4+
title: "Mi menú"
55
};
66

77

88
function multiplyNumeric(obj) {
99

10-
/* your code */
10+
/* tu código */
1111

1212
}
1313

1414
multiplyNumeric(menu);
1515

16-
alert( "menu width=" + menu.width + " height=" + menu.height + " title=" + menu.title );
17-
16+
alert( "ancho del menú=" + menu.width + " alto=" + menu.height + " título=" + menu.title );

1-js/04-object-basics/01-object/8-multiply-numeric/_js.view/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
describe("multiplyNumeric", function() {
2-
it("multiplies all numeric properties by 2", function() {
2+
it("multiplicar todas las propiedades numéricas por 2", function() {
33
let menu = {
44
width: 200,
55
height: 300,
6-
title: "My menu"
6+
title: "Mi menú"
77
};
88
let result = multiplyNumeric(menu);
99
assert.equal(menu.width, 400);
1010
assert.equal(menu.height, 600);
11-
assert.equal(menu.title, "My menu");
11+
assert.equal(menu.title, "Mi menú");
1212
});
1313

14-
it("returns nothing", function() {
14+
it("No devuelve nada", function() {
1515
assert.isUndefined( multiplyNumeric({}) );
1616
});
1717

1-js/04-object-basics/01-object/8-multiply-numeric/task.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,32 @@ importance: 3
22

33
---
44

5-
# Multiply numeric properties by 2
5+
# Multiplicar propiedades numéricas por 2
66

7-
Create a function `multiplyNumeric(obj)` that multiplies all numeric properties of `obj` by `2`.
7+
Crea una función `multiplyNumeric(obj)` que multiplique todas las propiedades numéricas de `obj` por `2`.
88

9-
For instance:
9+
Por ejemplo:
1010

1111
```js
12-
// before the call
12+
// Antes de la llamada
1313
let menu = {
1414
width: 200,
1515
height: 300,
16-
title: "My menu"
16+
title: "Mi menú"
1717
};
1818

1919
multiplyNumeric(menu);
2020

21-
// after the call
21+
// Después de la llamada
2222
menu = {
2323
width: 400,
2424
height: 600,
25-
title: "My menu"
25+
title: "Mi menú"
2626
};
2727
```
2828

29-
Please note that `multiplyNumeric` does not need to return anything. It should modify the object in-place.
29+
Nota que `multiplyNumeric` no necesita devolver nada. Debe modificar el objeto en su lugar.
3030

31-
P.S. Use `typeof` to check for a number here.
31+
P.D. Usa `typeof` para verificar si hay un número aquí.
3232

3333

0 commit comments

Comments
 (0)