diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..f6ef8a438 Binary files /dev/null and b/.DS_Store differ diff --git a/starter-code/functions-and-arrays.js b/starter-code/functions-and-arrays.js index 039bef297..ec8a2c0be 100644 --- a/starter-code/functions-and-arrays.js +++ b/starter-code/functions-and-arrays.js @@ -1,14 +1,34 @@ // Find the maximum function maxOfTwoNumbers (first, second) { - + if (first>second){ + console.log ("first"); + } + else if (second>first){ + console.log ("second"); + } + else { + console.log("the numbers are the same"); + } } var largest = maxOfTwoNumbers(2, 6); console.log(largest); // Finding Longest Word -function findLongestWord (words) { +function findLongestWord (words) { + var biggest=""; + for ( var ix=0; ix < words.length; ix++){ + if ( biggest.length < words[ix].length){ + biggest=words[ix]; + } + } + for ( var j=0; j +function findLongestWord (words) { + var LongestWord=""; + words.forEach(function(word){ + if(word.lenght>longestWord.lenght){ + longestWord = word; + } + }); + return longestWord; + } + + +var words = [ + "mystery", + "brother", + "aviator", + "crocodile", + "pearl", + "orchard", + "crackpot" +]; +