Skip to content

Commit c1a59c0

Browse files
Merge pull request #273 from ezzep66/Object.keys-values-entries
Constructor, operator "new"
2 parents 6ef07f3 + a6dbf35 commit c1a59c0

File tree

8 files changed

+101
-101
lines changed

8 files changed

+101
-101
lines changed

1-js/04-object-basics/06-constructor-new/1-two-functions-one-object/solution.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Yes, it's possible.
1+
Si, es posible.
22

3-
If a function returns an object then `new` returns it instead of `this`.
3+
Si una función devuelve un objeto, entonces `new` lo devuelve en vez de `this`.
44

5-
So they can, for instance, return the same externally defined object `obj`:
5+
Por lo tanto pueden, por ejemplo, devolver el mismo objeto definido externamente `obj`:
66

77
```js run no-beautify
88
let obj = {};

1-js/04-object-basics/06-constructor-new/1-two-functions-one-object/task.md

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

33
---
44

5-
# Two functionsone object
5+
# Dos funcionesun objeto
66

7-
Is it possible to create functions `A` and `B` such as `new A()==new B()`?
7+
Es posible crear las funciones `A` y `B` como `new A()==new B()`?
88

99
```js no-beautify
1010
function A() { ... }
@@ -16,4 +16,4 @@ let b = new B;
1616
alert( a == b ); // true
1717
```
1818

19-
If it is, then provide an example of their code.
19+
Si es posible, entonces proporcione un ejemplo de su código.

1-js/04-object-basics/06-constructor-new/2-calculator-constructor/_js.view/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ describe("calculator", function() {
1111
calculator.read();
1212
});
1313

14-
it("when 2 and 3 are entered, the sum is 5", function() {
14+
it("cuando se ingresa 2 y 3, la suma es 5", function() {
1515
assert.equal(calculator.sum(), 5);
1616
});
1717

18-
it("when 2 and 3 are entered, the product is 6", function() {
18+
it("cuando se ingresa 2 y 3, el producto es 6", function() {
1919
assert.equal(calculator.mul(), 6);
2020
});
2121

1-js/04-object-basics/06-constructor-new/2-calculator-constructor/task.md

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

33
---
44

5-
# Create new Calculator
5+
# Crear nueva Calculadora
66

7-
Create a constructor function `Calculator` that creates objects with 3 methods:
7+
Crear una función constructora `Calculator` que crea objetos con 3 métodos:
88

9-
- `read()` asks for two values using `prompt` and remembers them in object properties.
10-
- `sum()` returns the sum of these properties.
11-
- `mul()` returns the multiplication product of these properties.
9+
- `read()` pide dos valores usando `prompt` y los recuerda en las propiedades del objeto.
10+
- `sum()` devuelve la suma de estas propiedades.
11+
- `mul()` devuelve el producto de multiplicación de estas propiedades.
1212

13-
For instance:
13+
Por ejemplo:
1414

1515
```js
1616
let calculator = new Calculator();

1-js/04-object-basics/06-constructor-new/3-accumulator/_js.view/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ describe("Accumulator", function() {
88
prompt.restore();
99
});
1010

11-
it("initial value is the argument of the constructor", function() {
11+
it("valor inicial es el argumento del constructor", function() {
1212
let accumulator = new Accumulator(1);
1313

1414
assert.equal(accumulator.value, 1);
1515
});
1616

17-
it("after reading 0, the value is 1", function() {
17+
it("después de leer 0, el valor es 1", function() {
1818
let accumulator = new Accumulator(1);
1919
prompt.returns("0");
2020
accumulator.read();
2121
assert.equal(accumulator.value, 1);
2222
});
2323

24-
it("after reading 1, the value is 2", function() {
24+
it("después de leer 1, el valor es 2", function() {
2525
let accumulator = new Accumulator(1);
2626
prompt.returns("1");
2727
accumulator.read();
2828
assert.equal(accumulator.value, 2);
2929
});
30-
});
30+
});

1-js/04-object-basics/06-constructor-new/3-accumulator/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function Accumulator(startingValue) {
55
this.value = startingValue;
66

77
this.read = function() {
8-
this.value += +prompt('How much to add?', 0);
8+
this.value += +prompt('Cuánto más agregar?', 0);
99
};
1010

1111
}

1-js/04-object-basics/06-constructor-new/3-accumulator/task.md

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

33
---
44

5-
# Create new Accumulator
5+
# Crear nuevo Acumulador
66

7-
Create a constructor function `Accumulator(startingValue)`.
7+
Crear una función contructor `Accumulator(startingValue)`.
88

9-
Object that it creates should:
9+
El objeto que crea debería:
1010

11-
- Store the "current value" in the property `value`. The starting value is set to the argument of the constructor `startingValue`.
12-
- The `read()` method should use `prompt` to read a new number and add it to `value`.
11+
- Almacene el "valor actual" en la propiedad `value`. El valor inicial se establece en el argumento del constructor `startingValue`.
12+
- El método `read()` debe usar `prompt` para leer un nuevo número y agregarlo a `value`.
1313

14-
In other words, the `value` property is the sum of all user-entered values with the initial value `startingValue`.
14+
En otras palabras, la propiedad `value` es la suma de todos los valores ingresados por el usuario con el valor inicial `startingValue`.
1515

16-
Here's the demo of the code:
16+
Aquí está la demostración del código:
1717

1818
```js
19-
let accumulator = new Accumulator(1); // initial value 1
19+
let accumulator = new Accumulator(1); // valor inicial 1
2020

21-
accumulator.read(); // adds the user-entered value
22-
accumulator.read(); // adds the user-entered value
21+
accumulator.read(); // agrega el valor introducido por el usuario
22+
accumulator.read(); // agrega el valor introducido por el usuario
2323

24-
alert(accumulator.value); // shows the sum of these values
24+
alert(accumulator.value); // muestra la suma de estos valores
2525
```
2626

2727
[demo]

0 commit comments

Comments
 (0)