Skip to content

Commit 24d5668

Browse files
committed
interação ironhack-labs#3 concluída
1 parent 30bcbc5 commit 24d5668

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/functions-and-arrays.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@ function maxOfTwoNumbers(num1, num2){
1010

1111
// Iteration #2: Find longest word
1212
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
13-
function findLongestWord() {}
13+
function findLongestWord(wordArray) {
14+
15+
}
1416

1517

1618

1719

1820
// Iteration #3: Calculate the sum
1921
const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10];
2022

21-
function sumNumbers() {}
22-
23+
function sumNumbers(arrayNum) {
24+
let sum = 0
25+
for(let i = 0; i < arrayNum.length; i++) {
26+
if((typeof arrayNum[i]) === "number"){
27+
sum += arrayNum[i];
28+
}
29+
}
30+
return sum;
31+
}
32+
console.log(sumNumbers(numbers))
2333

2434

2535
// Iteration #3.1 Bonus:

0 commit comments

Comments
 (0)