File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,27 @@ function sumNumbers(arrayNumbers) {
47
47
48
48
49
49
// 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
+ }
51
71
52
72
53
73
You can’t perform that action at this time.
0 commit comments