diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index 19b998d0e..5e9569ae2 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -1,32 +1,130 @@ // Iteration #1: Find the maximum -function maxOfTwoNumbers() {} +function maxOfTwoNumbers(x,y) { + if (x>y){ + return x + } else { + return y + } +} // Iteration #2: Find longest word const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot']; -function findLongestWord() {} +function findLongestWord(w) { + if (w.length === 0){ + return null + } else { + let length = [] + for (i=0; i