Skip to content

Commit 61644c5

Browse files
Samantha FerreiraSamantha Ferreira
authored andcommitted
first code done opnly
1 parent c4f4d5a commit 61644c5

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

starter-code/src/functions-and-arrays.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// Find the maximum
1+
// Find the maximu
2+
3+
function maxOfTwoNumbers(num1, num2) {
4+
return Math.max(num1, num2)
5+
}
26

37
// Finding Longest Word
48
var words = [
@@ -9,7 +13,28 @@ var words = [
913
'pearl',
1014
'orchard',
1115
'crackpot'
12-
];
16+
];
17+
function findLongestWord(words){
18+
for(var i = 0; i < words.length; i++) {
19+
var longest = words[i].length;
20+
if (words[i].length > longest) {
21+
longest = words[i]
22+
}
23+
}
24+
return longest
25+
}
26+
findLongestWord(words)
27+
findLongestWord(words)
28+
console.log(words)
29+
30+
31+
findLongestWord(['mystery',
32+
'brother',
33+
'aviator',
34+
'crocodile',
35+
'pearl',
36+
'orchard',
37+
'crackpot' ]);
1338

1439
// Calculating a Sum
1540

0 commit comments

Comments
 (0)