From 3097b660d0a0144470758757e85a9ee0337bd0a4 Mon Sep 17 00:00:00 2001 From: Juan Lozano Date: Thu, 11 May 2023 17:39:45 +0200 Subject: [PATCH 1/5] Iteration 1 done --- src/functions-and-arrays.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index 3a7dbec41..3894f0604 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -1,5 +1,13 @@ // Iteration #1: Find the maximum -function maxOfTwoNumbers() {} +function maxOfTwoNumbers(a, b) { + if(a>b){ + return a; + } else if(b>a){ + return b; + } else { + return a; + } +} From b12f1a6ffa4b4cfa008501aadf020a509decc7ee Mon Sep 17 00:00:00 2001 From: Juan Lozano Date: Thu, 11 May 2023 21:40:54 +0200 Subject: [PATCH 2/5] Iteration 2 --- src/functions-and-arrays.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index 3894f0604..cb5d115fc 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -9,19 +9,34 @@ function maxOfTwoNumbers(a, b) { } } - - // Iteration #2: Find longest word const words = ['mystery', 'brother', 'aviator', 'crocodile', 'pearl', 'orchard', 'crackpot']; -function findLongestWord() {} +function findLongestWord(words) { + + let longWord = ''; + + for(let i=0; i Date: Thu, 11 May 2023 22:09:34 +0200 Subject: [PATCH 3/5] Iteration 4 --- src/functions-and-arrays.js | 40 ++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index cb5d115fc..6a9d2acd6 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -35,13 +35,23 @@ const numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; function sumNumbers(numbers) { + let sum = 0; + for (let i=0; i Date: Thu, 11 May 2023 22:22:00 +0200 Subject: [PATCH 4/5] Iteration 5 --- src/functions-and-arrays.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index 6a9d2acd6..aeb7a4dcd 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -105,8 +105,21 @@ const wordsUnique = [ 'bring' ]; -function uniquifyArray() {} +function uniquifyArray(wordsUnique) { + let newArr = []; + + for(let i=0; i Date: Thu, 11 May 2023 22:33:03 +0200 Subject: [PATCH 5/5] Iteration 7 --- src/functions-and-arrays.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/functions-and-arrays.js b/src/functions-and-arrays.js index aeb7a4dcd..9ce7cf2f8 100644 --- a/src/functions-and-arrays.js +++ b/src/functions-and-arrays.js @@ -125,7 +125,14 @@ function uniquifyArray(wordsUnique) { // Iteration #6: Find elements const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience']; -function doesWordExist() {} +function doesWordExist(wordsFind, word) { + + if(wordsFind.length === 0){ + return null; + } else { + return wordsFind.includes(word); + } +} @@ -144,7 +151,16 @@ const wordsCount = [ 'matter' ]; -function howManyTimes() {} +function howManyTimes(wordsCount, word) { + + let timesWord = 0; + for(let i=0; i