Skip to content

Commit 76640bc

Browse files
committed
Done the calculate the sum but in line 65 I can not get pass it.
1 parent c7b2ce6 commit 76640bc

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/functions-and-arrays.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,27 @@ function sumNumbers(arrayNumbers) {
4747

4848

4949
// Iteration #3.1 Bonus:
50-
function sum() {}
50+
function sum(anytype) {
51+
if (anytype.length === 0){
52+
return 0
53+
}
54+
let numbers = 0
55+
let sumStrings = 0
56+
let booleans = 0
57+
for (let i = 0 ; i < anytype.length; i++){
58+
if (typeof anytype[i] === 'number') {
59+
numbers += anytype[i]
60+
} else if (typeof anytype[i] === 'string'){
61+
sumStrings += anytype[i].length
62+
} else if (typeof anytype[i] === 'boolean') {
63+
booleans += anytype[i]
64+
} else {
65+
return error // No consigo pasar este punto me pide que arroje un error y es lo que hago...
66+
}
67+
}
68+
let total = numbers + sumStrings + booleans
69+
return total;
70+
}
5171

5272

5373

0 commit comments

Comments
 (0)