Skip to content

Commit 6b8cff4

Browse files
RaquelRaquel
Raquel
authored and
Raquel
committed
Iteration ironhack-labs#1 and ironhack-labs#2 completed
1 parent bbd5108 commit 6b8cff4

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/functions-and-arrays.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
// Iteration #1: Find the maximum
2-
function maxOfTwoNumbers() {}
2+
function maxOfTwoNumbers(num1,num2) {
3+
if (num1 > num2){
4+
return num1
5+
}else {
6+
return num2
7+
}
8+
}
39

410

511

612
// Iteration #2: Find longest word
713
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
814

9-
function findLongestWord() {}
10-
15+
function findLongestWord(arr) {
16+
if (!arr){
17+
return null
18+
}
19+
let words = ""
20+
for (let i=0; i < arr.length;i++){
21+
if (words.length < arr[i].length){
22+
words = arr[i];
23+
}
24+
}
25+
return words;
26+
}
1127

1228

1329
// Iteration #3: Calculate the sum

0 commit comments

Comments
 (0)