Skip to content

Commit 7689428

Browse files
committed
reviewing instructions til ex 18
1 parent 325e31a commit 7689428

File tree

33 files changed

+299
-176
lines changed

33 files changed

+299
-176
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

exercises/08.2-Count-On/README.md

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

33
As you saw in the last exercise your array can be a mix types of data.
44

5-
## :pencil: Instructions
5+
## :pencil: Instrucciones:
66

77
1. Add all the items with data-type object into the `hello` array.
88

@@ -17,12 +17,12 @@ for(let index = 0; index < myArray.length; index++){
1717
}
1818
```
1919

20-
## :bulb: Hint
20+
## :bulb: Hint:
2121

2222
+ Loop the given array.
2323

2424
+ Add a condition inside the loop that checks for the item to be an object.
2525

2626
+ If the item is an object, added to the `hello` array.
2727

28-
+ Console log the array hello.
28+
+ Console log the array `hello`.
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
# `08.3` Sum All Items
1+
# `08.3` Suma todos los elementod
22

3-
Usando el bucle (loop) for, complete el código de la función `sum` para que devuelva la suma de todos los elementos en un arreglo dado, por ejemplo:
3+
## :pencil: Instrucciones:
4+
5+
6+
1. Usando un bucle (loop) `for`, completa el código de la función `sum` para que devuelva la suma de todos los elementos en un arregloarrayy dado, por ejemplo:
47

58
```js
69
console.log(sumTheElements([2,13,34,5]))
710
//this should print 54
811
```
912

10-
El resultado debe ser 925960
13+
### Resultado esperado:
14+
15+
925960
16+
17+
# :bulb: Pista:
18+
19+
+ Inicializa una variable `total` en 0.
20+
21+
+ Recorre todo el arreglo.
1122

12-
# :bulb: Pista
23+
+ En cada bucle, agrega el valor de cada elemento en la variable `total`.
1324

14-
1. Inicialice una variable `total` en 0.
15-
2. Recorre todo el arreglo.
16-
3. En cada bucle, agregue el valor de cada elemento en la variable `total`.
17-
4. Devuelve la variable total (fuera del bucle pero dentro de la función).
25+
+ Devuelve la variable `total` (fuera del bucle pero dentro de la función).
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# `08.3` Sum All Items
22

3-
Using a for loop, complete the code of the function `sum` so that it returns the sum of all the items in a given array, for example:
3+
## :pencil: Instructions:
4+
5+
Using a `for` loop, complete the code of the function `sum` so that it returns the sum of all the items in a given array, for example:
46

57
```js
68
console.log(sumTheElements([2,13,34,5]))
7-
//this should print 54
9+
//el resultado debiese ser 54
810
```
911

10-
The result should be 925960
12+
### Expected result:
13+
14+
925960
15+
16+
# :bulb: Hint:
17+
18+
+ Initilize a variable `total` at 0.
19+
20+
+ Loop the entire array.
1121

12-
# :bulb: Hint
22+
+ On every loop add the value of each item into the `total` variable.
1323

14-
1. Initilize a variable `total` at 0.
15-
2. Loop the entire array.
16-
3. On every loop add the value of each item into the `total` variable.
17-
4. Return the total variable (outside of the loop but inside of the function).
24+
+ Return the `total` variable (outside of the loop but inside of the function).
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# `09.1` Bucle/loop forEach
2+
3+
En lugar de usar la clásica declaración `for`, hay una nueva forma de recorrer los arreglos: [ higher order functions (funciones de orden superior) ](https://www.youtube.com/watch?v=rRgD1yVwIvE)
4+
5+
Es posible recorrer un arreglo usando la función `array.forEach`. Debes especificar qué hacer en cada iteración del bucle.
6+
7+
```js
8+
/**
9+
* item: will be the value of the specific item (required).
10+
* index: will be the item index(optional).
11+
* arr: will be the array object to which the element belongs to (opcional).
12+
*/
13+
myArray.forEach(function(item, index, arr){
14+
15+
});
16+
```
17+
18+
## :pencil: Instrucciones:
19+
20+
En este momento, el código está imprimiendo todos los elementos en el arreglo o array:
21+
22+
1. Cambia el código de la función para imprimir solo los números divisibles por 14.
23+
24+
## :bulb: Pista:
25+
26+
Un número X es divisible por 2 si: (X%2===0)

exercises/09.1-forEach-loop/README.md renamed to exercises/09-forEach-loop/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ It is possible to loop an array using the `array.forEach` function. You have to
66

77
```js
88
/**
9-
* item: will be the value of the specific item.
10-
* index: will be the item index.
11-
* arr: will be the
9+
* item: valor del elemento específico (requerido).
10+
* index: índice del elemento (opcional).
11+
* arr: objeto array al cual pertenece el elemento (opcional).
1212
*/
1313
myArray.forEach(function(item, index, arr){
1414

1515
});
1616
```
1717

18-
# :pencil: Instructions
18+
## :pencil: Instructions:
1919

20-
Right now, the code is printing all the items in the array. Please change the function code to print only the numbers divisible by 14.
20+
Right now, the code is printing all the items in the array:
2121

22-
## :bulb: HINT
22+
1. Please change the function code to print only the numbers divisible by 14.
23+
24+
## :bulb: Hint:
2325

2426
A number X is divisible by 2 if: (X%2===0)

0 commit comments

Comments
 (0)