-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraym0405.js
More file actions
29 lines (20 loc) · 786 Bytes
/
arraym0405.js
File metadata and controls
29 lines (20 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*Array of Multiples
Create a function that takes two parameters (number, length) and returns an array of length containing multiples of the number.
Examples:
- `arrayMultiplos(2, 10)` should return `[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]`.
- `arrayMultiplos(17, 6)` should return `[17, 34, 51, 68, 85, 102]`.
*/
function arrayMultiplos(numero, arrLength){
let paso = 1;
let numeroInicial = numero;
let respuesta = [];
while(paso < arrLength + 1) {
numero = numeroInicial * paso;
respuesta.push(numero);
paso++;
}
return respuesta;
}
console.log(arrayMultiplos(2, 10));
console.log(arrayMultiplos(17, 6));
//ya estoy harta de intentarlo como loca (eso de subir mis archivos a github y que no funcione)