Skip to content

Commit 29179a3

Browse files
committed
Complete: Iteration ironhack-labs#1 and ironhack-labs#2
1 parent 751ea3b commit 29179a3

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
@@ -1,12 +1,22 @@
11
// Iteration #1: Find the maximum
2-
function maxOfTwoNumbers() {}
3-
2+
function maxOfTwoNumbers(num1, num2) {
3+
return num1 < num2 ? num2 : num1
4+
}
45

56

67
// Iteration #2: Find longest word
78
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
89

9-
function findLongestWord() {}
10+
function findLongestWord(words) {
11+
12+
let longestWord = '';
13+
for ( let word of words ) {
14+
longestWord.length < word.length ? longestWord = word : false;
15+
}
16+
17+
return longestWord ? longestWord : null;
18+
}
19+
console.log( findLongestWord(words) );
1020

1121

1222

0 commit comments

Comments
 (0)