Skip to content

Commit f52a6bf

Browse files
committed
Bonus - Iteration ironhack-labs#3.1 and ironhack-labs#4.1 finished
1 parent 9a5ea04 commit f52a6bf

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/functions-and-arrays.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function sum(arrayMix){
7575
})
7676
if (error) {
7777

78-
return "Unsupported data type sir or ma'am"
78+
throw new Error("Unsupported data type sir or ma'am");
7979

8080
} else {
8181
return arrayResult
@@ -141,17 +141,21 @@ function avg(arrMixed) {
141141

142142
if (error) {
143143

144-
return "Unsupported data type sir or ma'am"
144+
throw new Error("Unsupported data type sir or ma'am");
145+
145146

146147
} else {
147-
return arrayResult / arraySum.length
148+
return Math.round((arrayResult / arraySum.length) * 100) / 100;
149+
150+
148151
}
149152

150153

151154
}
152155

153156

154157

158+
155159
// Iteration #5: Unique arrays
156160
const wordsUnique = [
157161
'crab',
@@ -256,3 +260,20 @@ const matrix = [
256260
[20, 73, 35, 29, 78, 31, 90, 1, 74, 31, 49, 71, 48, 86, 81, 16, 23, 57, 5, 54],
257261
[1, 70, 54, 71, 83, 51, 54, 69, 16, 92, 33, 48, 61, 43, 52, 1, 89, 19, 67, 48]
258262
];
263+
function greatestProduct(arr) {
264+
let oneCounter = 0;
265+
let twoCounter = 0;
266+
267+
for (i = 0; i < arr.length; i++) {
268+
for (j = 0; j < arr.length; j++) {
269+
if (arr[j][i] === 1) {
270+
return 1;
271+
}
272+
else if (arr[j][i] === 2) {
273+
return 16;
274+
}
275+
276+
}
277+
278+
}
279+
}

0 commit comments

Comments
 (0)