From 578354d66f7ffc7604ea76416829b4cc3d6db9b7 Mon Sep 17 00:00:00 2001 From: "cyril.attie" Date: Tue, 21 Aug 2018 21:01:52 +0300 Subject: [PATCH] finished pair programming Francis and Cyril --- starter-code/src/functions-and-arrays.js | 106 ++++++++++++++++++++++- 1 file changed, 104 insertions(+), 2 deletions(-) diff --git a/starter-code/src/functions-and-arrays.js b/starter-code/src/functions-and-arrays.js index 2fcd81e6e..bfe5bc4c9 100644 --- a/starter-code/src/functions-and-arrays.js +++ b/starter-code/src/functions-and-arrays.js @@ -1,4 +1,12 @@ // Find the maximum +function maxOfTwoNumbers(a,b) { + if (a>b){ + return a + } else { + return b + } +} +maxOfTwoNumbers(8,9) // Finding Longest Word var words = [ @@ -11,13 +19,43 @@ var words = [ 'crackpot' ]; +function findLongestWord(words) { + if (words.length === 0){ + return undefined + } + if (words.length === 1){ + return words[0] + } + for(var longest="", i=0; ilongest.length){ + longest=words[i] + } + } + return longest +} +findLongestWord(words) + // Calculating a Sum var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; +function sumArray(arr){ + for (var i =0, sum=0; igreatest) { + greatest=currentProduct + } else {continue} + } + } + //checking for up down products + for (var col = 0; col < matrix[0].length;col++){ + for (var i = 0; i greatest) { + greatest=currentProduct + } else {continue} + } + } + return greatest +} \ No newline at end of file