-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepeatNumbers.js
More file actions
31 lines (27 loc) · 793 Bytes
/
repeatNumbers.js
File metadata and controls
31 lines (27 loc) · 793 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
30
31
const repeatNumbers = function (data) {
let newArrayOne = [];
for (let y = 0; y < data.length; y++) {
for (let x = 0; x < data[y].length; x++) {
newArrayOne[y] = Array(data[y][1]).fill(data[y][0]);
}
};
return newArrayOne;
}
// const repeatNumbers = function(data) {
// let repeated = [];
// for(let piece of data){
// repeated += (repeated.length == 0 ? "" : ", ") + cloning(piece);
// }
// return repeated;
// };
// function cloning (array){
// if (array.length !== 2){return 0} // abort
// let result = '';
// for(let i = 0 ; i < array[1] ; i++){
// result += array[0]
// }
// return result;
// }
console.log(repeatNumbers([[1, 10]]));
console.log(repeatNumbers([[1, 2], [2, 3]]));
console.log(repeatNumbers([[10, 4], [34, 6], [92, 2]]));