Skip to content

Commit 104d518

Browse files
committed
add solution ironhack-labs#2
1 parent 6bab18e commit 104d518

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/functions-and-arrays.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ function maxOfTwoNumbers(aNumber, anotherNumber) {
1111
// Iteration #2: Find longest word
1212
const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot'];
1313

14-
function findLongestWord() {}
14+
function findLongestWord(input) {
15+
if(!input || input.length == 0){
16+
return null;
17+
}
18+
let longestWord = "";
19+
for(word of input){
20+
if(word.length > longestWord.length){
21+
longestWord = word;
22+
}
23+
}
24+
return longestWord;
25+
}
1526

1627

1728

0 commit comments

Comments
 (0)