From 06735af1dfa77b7200f661daaf43bb51e4a3f27d Mon Sep 17 00:00:00 2001 From: BlisS Date: Sat, 6 Jan 2018 09:37:33 -0600 Subject: [PATCH 1/6] The description of the test says: "returns the length of the longest one" but the test is expecting for the string itself, i change the Readme file wich is the quck fix, but may be could be good to change the spec file to not confuse the student. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d11b9e6e..81bf62d26 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ Define a function `maxOfTwoNumbers` that takes two numbers as arguments and retu ## Finding Longest Word -Write a function `findLongestWord` that takes an array of words and returns the length of the longest one. If there are 2 with the same length, it should return the first occurrence. +Write a function `findLongestWord` that takes an array of words and returns the longest one. If there are 2 with the same length, it should return the first occurrence. **Starter Code** From 7450c21f9bf5ffac225679fb6dc04a9e56860ceb Mon Sep 17 00:00:00 2001 From: BlisS Date: Sat, 6 Jan 2018 12:23:51 -0600 Subject: [PATCH 2/6] the test are waiting for undefined but the description says false --- starter-code/tests/FunctionsAndArraysSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starter-code/tests/FunctionsAndArraysSpec.js b/starter-code/tests/FunctionsAndArraysSpec.js index 8fb25ff65..67a3b8bad 100644 --- a/starter-code/tests/FunctionsAndArraysSpec.js +++ b/starter-code/tests/FunctionsAndArraysSpec.js @@ -170,7 +170,7 @@ describe('Counting Repetion - howManyTimes', function () { }); it('returns false with an empty array', function () { - expect(howManyTimes([])).toBe(undefined); + expect(howManyTimes([])).toBe(false); }); it('returns one when the word appears only one time on the array', function () { From 9aa7ae4d11a17df9770862452fa1d096aa0e62a0 Mon Sep 17 00:00:00 2001 From: jesusdelrioc Date: Tue, 9 Jan 2018 15:22:43 +0100 Subject: [PATCH 3/6] prueba --- starter-code/src/functions-and-arrays.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starter-code/src/functions-and-arrays.js b/starter-code/src/functions-and-arrays.js index 2fcd81e6e..70b67c42f 100644 --- a/starter-code/src/functions-and-arrays.js +++ b/starter-code/src/functions-and-arrays.js @@ -3,7 +3,7 @@ // Finding Longest Word var words = [ 'mystery', - 'brother', + 'broteeeher', 'aviator', 'crocodile', 'pearl', From e5cdec5748432029cb8b667167e1f112b8f8fa1e Mon Sep 17 00:00:00 2001 From: jesusdelrioc Date: Tue, 9 Jan 2018 18:29:00 +0100 Subject: [PATCH 4/6] realizado hasta el punto 6 --- starter-code/src/functions-and-arrays.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/starter-code/src/functions-and-arrays.js b/starter-code/src/functions-and-arrays.js index 70b67c42f..6eecc10e0 100644 --- a/starter-code/src/functions-and-arrays.js +++ b/starter-code/src/functions-and-arrays.js @@ -1,9 +1,13 @@ // Find the maximum +function maxOfTwoNumbers(a,b){ + return Math.max(a, b); +} +maxOfTwoNumbers(15,1); // Finding Longest Word var words = [ 'mystery', - 'broteeeher', + 'broteher', 'aviator', 'crocodile', 'pearl', @@ -11,6 +15,21 @@ var words = [ 'crackpot' ]; +function findLongestWord(){ + var longest = ""; + for (i = 0; i < words.length; i++){ + if (words[i].length > longest.length){ + longest = words[i]; + }else{ + return; + } + } + return longest; + } + findLongestWord(); + + + // Calculating a Sum var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; From cef1576e1c3cee8bf33f70bb2086e1803542a8d8 Mon Sep 17 00:00:00 2001 From: jesusdelrioc Date: Tue, 9 Jan 2018 19:57:52 +0100 Subject: [PATCH 5/6] finalizado --- starter-code/src/functions-and-arrays.js | 44 ++++++++++++++++++------ 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/starter-code/src/functions-and-arrays.js b/starter-code/src/functions-and-arrays.js index 6eecc10e0..5df5a6335 100644 --- a/starter-code/src/functions-and-arrays.js +++ b/starter-code/src/functions-and-arrays.js @@ -15,29 +15,53 @@ var words = [ 'crackpot' ]; -function findLongestWord(){ - var longest = ""; - for (i = 0; i < words.length; i++){ - if (words[i].length > longest.length){ - longest = words[i]; - }else{ - return; - } +function findLongestWord(a){ + var longest=""; + if (a.length === 0){ + return undefined; + } + for (var i = 0; i < a.length; i++){ + if (a[i].length > longest.length){ + longest = a[i]; + } } return longest; } - findLongestWord(); - + + findLongestWord(words); // Calculating a Sum var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; +function sumArray(a){ + var sum = 0; + for (var i= 0; i < a.length; i++){ + sum = sum + a[i]; + } + return sum; +} +sumArray(numbers); + // Calculate the Average var numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9]; +function sumArray(a){ + var sum = 0; + for (var i= 0; i < a.length; i++){ + sum = sum + a[i]; + var cant=a.length; + var media= sum/cantdd; + + } + return media; +} +sumArray(numbersAvg); + + + // Array of Strings var wordsArr = [ 'seat', From ca2fc4f3924743a14fd23d6c5b212c229ef4331d Mon Sep 17 00:00:00 2001 From: jesusdelrioc Date: Wed, 10 Jan 2018 09:08:45 +0100 Subject: [PATCH 6/6] trabajo --- starter-code/src/functions-and-arrays.js | 52 +++++++++++++++--------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/starter-code/src/functions-and-arrays.js b/starter-code/src/functions-and-arrays.js index 5df5a6335..b36c308e8 100644 --- a/starter-code/src/functions-and-arrays.js +++ b/starter-code/src/functions-and-arrays.js @@ -1,13 +1,14 @@ -// Find the maximum -function maxOfTwoNumbers(a,b){ - return Math.max(a, b); + // Find the maximum + function maxOfTwoNumbers(a,b){ + return Math.max(a,b); } + maxOfTwoNumbers(15,1); // Finding Longest Word var words = [ 'mystery', - 'broteher', + 'brother', 'aviator', 'crocodile', 'pearl', @@ -18,17 +19,17 @@ var words = [ function findLongestWord(a){ var longest=""; if (a.length === 0){ - return undefined; + return undefined; } for (var i = 0; i < a.length; i++){ - if (a[i].length > longest.length){ - longest = a[i]; - } + if (a[i].length > longest.length){ + longest = a[i]; + } } return longest; - } - - findLongestWord(words); +} + +findLongestWord(words); // Calculating a Sum @@ -37,30 +38,30 @@ var numbers = [6, 12, 1, 18, 13, 16, 2, 1, 8, 10]; function sumArray(a){ var sum = 0; - for (var i= 0; i < a.length; i++){ + for (var i = 0; i < a.length; i++){ sum = sum + a[i]; } return sum; } + sumArray(numbers); // Calculate the Average var numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9]; -function sumArray(a){ +function averageNumbers(a){ var sum = 0; - for (var i= 0; i < a.length; i++){ + + for (i = 0; i < a.length; i++){ sum = sum + a[i]; - var cant=a.length; - var media= sum/cantdd; - + var cant = a.length; + var media = sum/cant; } return media; } -sumArray(numbersAvg); - +averageNumbers(numbersAvg); // Array of Strings var wordsArr = [ @@ -76,6 +77,19 @@ var wordsArr = [ 'palace' ]; +function averageWordLength(a){ + if (a.length === 0){ + return; + } + var juntar = a.join(""); + var numJuntar = juntar.length; + var numAr = a.length; + var media = numJuntar / numAr; + return media; +} + +averageWordLength(words); + // Unique Arrays var wordsUnique = [ 'crab',