diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index 18c9498..3211d87 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -1,18 +1,125 @@ // Progression #1: Greatest of the two numbers - +function greatestOfTwoNumbers(a, b) { + if(a>b) { + return a; + } + else { + return b; + } +} // Progression #2: The lengthy word const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot']; - +function findScaryWord(words) { + if(words.length==0) { + return null; + } + else if(words.length==1) { + return words[0]; + } + else if(words.length==2) { + if(words[0].length==words[1].length) { + return words[0]; + } + } + else if(words.length>2) { + for(let i=0;i