From 74b8adf2744c00400f732d0ebacf85a1ba84d242 Mon Sep 17 00:00:00 2001 From: Kishan-kumar2020 <67338623+Kishan-kumar2020@users.noreply.github.com> Date: Thu, 7 Apr 2022 08:17:23 +0530 Subject: [PATCH] Kishan Kumar --- src/functions-and-arrays.js | 152 +++++++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 2 deletions(-) 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