Skip to content

Commit f37a0f2

Browse files
committed
Iteration ironhack-labs#3.1
1 parent 4aa82fd commit f37a0f2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/functions-and-arrays.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ function sumNumbers(numbersArray) {
3535

3636

3737
// Iteration #3.1 Bonus:
38-
function sum() {}
38+
function sum(numbersArray) {
39+
let newResult = 0;
40+
for(i=0; i< numbersArray.length;i++){
41+
if(typeof numbersArray[i] === "string"){
42+
newResult = newResult + numbersArray[i].length;
43+
} else {
44+
newResult = newResult + numbersArray[i];
45+
}
46+
}
47+
return newResult;
48+
}
3949

4050

4151

0 commit comments

Comments
 (0)