From cd1fc3ec6463143c37f40d8e13be0829951c772f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:15:42 +0200 Subject: [PATCH 01/94] Update README.md --- exercises/20.4-Map-data-types/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/20.4-Map-data-types/README.md b/exercises/20.4-Map-data-types/README.md index 838683fc..c1a03f58 100644 --- a/exercises/20.4-Map-data-types/README.md +++ b/exercises/20.4-Map-data-types/README.md @@ -1,6 +1,6 @@ # `20.4` Map data types -Some times arrays come with mixed values and you need to unify them into only one data type. +Sometimes arrays come with mixed values, and you need to unify them into only one data type. ## 馃摑 Instructions: @@ -9,7 +9,8 @@ Some times arrays come with mixed values and you need to unify them into only on ## 馃挕 Hint: + Use the `typeof` function to get the data type. -## Expected result: + +## 馃捇 Expected result: ```js [string,string,... ,number,string,...] From ada73c4e1bd474e15784c8dd2859a97c1a0d2e68 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:15:49 +0200 Subject: [PATCH 02/94] Update README.es.md --- exercises/20.4-Map-data-types/README.es.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/20.4-Map-data-types/README.es.md b/exercises/20.4-Map-data-types/README.es.md index df95f56b..14a8bc8b 100644 --- a/exercises/20.4-Map-data-types/README.es.md +++ b/exercises/20.4-Map-data-types/README.es.md @@ -1,4 +1,4 @@ -# `20.4` `Map` y tipos de datos +# `20.4` Map data types Algunas veces los arreglos vienen con valores mixtos y debes unificarlos en un solo tipo de datos. @@ -8,9 +8,9 @@ Algunas veces los arreglos vienen con valores mixtos y debes unificarlos en un s ## 馃挕 Pista: -+ Usa la funci贸n `typeof` para obtener el tipo de datos ++ Usa la funci贸n `typeof` para obtener el tipo de dato. -## Resultado esperado: +## 馃捇 Resultado esperado: ```js [string,string,... ,number,string,...] From be224c6d6212589c5b8da29141db956d6cfe9a54 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:16:16 +0200 Subject: [PATCH 03/94] Update app.js --- exercises/20.4-Map-data-types/app.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exercises/20.4-Map-data-types/app.js b/exercises/20.4-Map-data-types/app.js index 22e95631..b6304a4e 100644 --- a/exercises/20.4-Map-data-types/app.js +++ b/exercises/20.4-Map-data-types/app.js @@ -1,8 +1,7 @@ +let arrayOfStrings = ['1', '5', '45', '34', '343', '34', 6556, 323]; -let arrayOfStrings = ['1','5','45','34','343','34',6556,323]; - -let newArray = arrayOfStrings.map(function(val){ - return (val); +let newArray = arrayOfStrings.map(function(item) { + return item; }); From 4f2f2ea4794a124a9e34865a90078e40eadcf902 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:18:48 +0200 Subject: [PATCH 04/94] Create solution.hide.js --- exercises/20.4-Map-data-types/solution.hide.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 exercises/20.4-Map-data-types/solution.hide.js diff --git a/exercises/20.4-Map-data-types/solution.hide.js b/exercises/20.4-Map-data-types/solution.hide.js new file mode 100644 index 00000000..ddf455e8 --- /dev/null +++ b/exercises/20.4-Map-data-types/solution.hide.js @@ -0,0 +1,7 @@ +let arrayOfStrings = ['1', '5', '45', '34', '343', '34', 6556, 323]; + +let newArray = arrayOfStrings.map(function(item) { + return typeof(item); +}); + +console.log(newArray) From 41d00c3bd308d88ff18886437f5e7d21cf5a7930 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:19:28 +0200 Subject: [PATCH 05/94] Update test.js --- exercises/20.4-Map-data-types/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/20.4-Map-data-types/test.js b/exercises/20.4-Map-data-types/test.js index 08aa37cb..b08031d4 100644 --- a/exercises/20.4-Map-data-types/test.js +++ b/exercises/20.4-Map-data-types/test.js @@ -20,7 +20,7 @@ test("You shouldn't delete the variable newArray", function(){ expect(myVar).toBeTruthy(); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let _arrayOfStrings = ['1','5','45','34','343','34',6556,323]; From e5df0372c7fa7c714aebc36791525e0305d084d5 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:24:17 +0200 Subject: [PATCH 06/94] Update README.md --- exercises/20.4-Map-data-types/README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/exercises/20.4-Map-data-types/README.md b/exercises/20.4-Map-data-types/README.md index c1a03f58..c1932d78 100644 --- a/exercises/20.4-Map-data-types/README.md +++ b/exercises/20.4-Map-data-types/README.md @@ -1,10 +1,8 @@ # `20.4` Map data types -Sometimes arrays come with mixed values, and you need to unify them into only one data type. - ## 馃摑 Instructions: -1. Update the `array.map()` function to make it create a new array that contains the data types of each corresponding item from the original array. +1. Update the `array.map()` function to make it create a new array that contains the data types of each item from the original array. ## 馃挕 Hint: @@ -13,6 +11,11 @@ Sometimes arrays come with mixed values, and you need to unify them into only on ## 馃捇 Expected result: ```js -[string,string,... ,number,string,...] +[ + 'string', 'string', + 'string', 'string', + 'string', 'string', + 'number', 'number' +] ``` From 62f4fb0cad24aa79690aae9d41967241968201b1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:25:28 +0200 Subject: [PATCH 07/94] Update README.md --- exercises/20.4-Map-data-types/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/20.4-Map-data-types/README.md b/exercises/20.4-Map-data-types/README.md index c1932d78..2139ae05 100644 --- a/exercises/20.4-Map-data-types/README.md +++ b/exercises/20.4-Map-data-types/README.md @@ -2,7 +2,7 @@ ## 馃摑 Instructions: -1. Update the `array.map()` function to make it create a new array that contains the data types of each item from the original array. +1. Update the `array.map()` function to make it create a new array that contains the data types of each item from the given array. ## 馃挕 Hint: @@ -18,4 +18,3 @@ 'number', 'number' ] ``` - From 25e3c181018d5f43757d834150d0bb4ff7d17c92 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:25:33 +0200 Subject: [PATCH 08/94] Update README.es.md --- exercises/20.4-Map-data-types/README.es.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/exercises/20.4-Map-data-types/README.es.md b/exercises/20.4-Map-data-types/README.es.md index 14a8bc8b..5af1a5e5 100644 --- a/exercises/20.4-Map-data-types/README.es.md +++ b/exercises/20.4-Map-data-types/README.es.md @@ -1,10 +1,8 @@ # `20.4` Map data types -Algunas veces los arreglos vienen con valores mixtos y debes unificarlos en un solo tipo de datos. - ## 馃摑 Instrucciones: -1. Actualiza la funci贸n `array.map()` para que cree un nuevo arreglo que contenga los tipos de datos de cada elemento correspondiente al arreglo original. +1. Actualiza la funci贸n `array.map()` para que cree un nuevo arreglo que contenga los tipos de datos de cada elemento del arreglo dado. ## 馃挕 Pista: @@ -13,5 +11,10 @@ Algunas veces los arreglos vienen con valores mixtos y debes unificarlos en un s ## 馃捇 Resultado esperado: ```js -[string,string,... ,number,string,...] +[ + 'string', 'string', + 'string', 'string', + 'string', 'string', + 'number', 'number' +] ``` From da671b975f13f1183a408379a08f73c5102f03dc Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:27:02 +0200 Subject: [PATCH 09/94] Update solution.hide.js --- exercises/20.4-Map-data-types/solution.hide.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/20.4-Map-data-types/solution.hide.js b/exercises/20.4-Map-data-types/solution.hide.js index ddf455e8..9d5dda98 100644 --- a/exercises/20.4-Map-data-types/solution.hide.js +++ b/exercises/20.4-Map-data-types/solution.hide.js @@ -1,6 +1,6 @@ -let arrayOfStrings = ['1', '5', '45', '34', '343', '34', 6556, 323]; +let mixedDataTypes = ['1', '5', '45', '34', '343', '34', 6556, 323]; -let newArray = arrayOfStrings.map(function(item) { +let newArray = mixedDataTypes.map(function(item) { return typeof(item); }); From dde7a127f3b8b735573033e829f303376a0437ae Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:28:02 +0200 Subject: [PATCH 10/94] Update app.js --- exercises/20.4-Map-data-types/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/20.4-Map-data-types/app.js b/exercises/20.4-Map-data-types/app.js index b6304a4e..6c84f682 100644 --- a/exercises/20.4-Map-data-types/app.js +++ b/exercises/20.4-Map-data-types/app.js @@ -1,7 +1,8 @@ let arrayOfStrings = ['1', '5', '45', '34', '343', '34', 6556, 323]; let newArray = arrayOfStrings.map(function(item) { - return item; + // Your code here + }); - +console.log(newArray); From f494fd20482d4ac83699b191cd694231b0adea2e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:29:35 +0200 Subject: [PATCH 11/94] Update app.js --- exercises/20.4-Map-data-types/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/20.4-Map-data-types/app.js b/exercises/20.4-Map-data-types/app.js index 6c84f682..0139ef47 100644 --- a/exercises/20.4-Map-data-types/app.js +++ b/exercises/20.4-Map-data-types/app.js @@ -1,8 +1,8 @@ -let arrayOfStrings = ['1', '5', '45', '34', '343', '34', 6556, 323]; +let mixedDataTypes = ['1', '5', '45', '34', '343', '34', 6556, 323]; -let newArray = arrayOfStrings.map(function(item) { +let newArray = mixedDataTypes.map(function(item) { // Your code here - + return item }); console.log(newArray); From 67a0c696e8515d3bb3de9ddf8c864c32c32273e3 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:29:49 +0200 Subject: [PATCH 12/94] Update solution.hide.js --- exercises/20.4-Map-data-types/solution.hide.js | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/20.4-Map-data-types/solution.hide.js b/exercises/20.4-Map-data-types/solution.hide.js index 9d5dda98..b9334d8a 100644 --- a/exercises/20.4-Map-data-types/solution.hide.js +++ b/exercises/20.4-Map-data-types/solution.hide.js @@ -1,6 +1,7 @@ let mixedDataTypes = ['1', '5', '45', '34', '343', '34', 6556, 323]; let newArray = mixedDataTypes.map(function(item) { + // Your code here return typeof(item); }); From 36c0b9dc13b58f890345d8398790c1117d9f6251 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:31:09 +0200 Subject: [PATCH 13/94] Update README.es.md --- exercises/20.4-Map-data-types/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/20.4-Map-data-types/README.es.md b/exercises/20.4-Map-data-types/README.es.md index 5af1a5e5..29f44b34 100644 --- a/exercises/20.4-Map-data-types/README.es.md +++ b/exercises/20.4-Map-data-types/README.es.md @@ -2,7 +2,7 @@ ## 馃摑 Instrucciones: -1. Actualiza la funci贸n `array.map()` para que cree un nuevo arreglo que contenga los tipos de datos de cada elemento del arreglo dado. +1. Modifica la funci贸n de `array.map()` para que cree un nuevo arreglo que contenga los tipos de datos de cada elemento del arreglo dado. ## 馃挕 Pista: From 5439924f14c3a9e1308f763a75cc63c519ad548f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:38:36 +0200 Subject: [PATCH 14/94] Update README.md --- exercises/20.5-Map-arrays-of-objects/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/20.5-Map-arrays-of-objects/README.md b/exercises/20.5-Map-arrays-of-objects/README.md index 1e87abb4..d0a456b6 100644 --- a/exercises/20.5-Map-arrays-of-objects/README.md +++ b/exercises/20.5-Map-arrays-of-objects/README.md @@ -1,6 +1,6 @@ # `20.5` Map array of objects -The most common scenario for the mapping function is for simplifying given arrays, for example: +The most common scenario for the mapping function is simplifying given arrays, for example: The current algorithm creates an array with only the names of the people and prints it on the console. @@ -8,11 +8,11 @@ The current algorithm creates an array with only the names of the people and pri 1. Please update the mapping function so it creates an array where each item contains the following: -```js +```text Hello, my name is Joe and I am 36 years old ``` -## Expected result: +## 馃捇 Expected result: The result should be similar to this, but the ages might be different. @@ -24,12 +24,12 @@ The result should be similar to this, but the ages might be different. 'Hello, my name is Steve and I am 19 years old' ] ``` -## 馃挕 Hint: +## 馃挕 Hints: -+ You have to get the age of each people based on their birthDate. ++ You have to get the age of each person based on their `birthDate`. -+ Search in Google "How to get the age of given birth date in javascript". ++ Search in Google "How to get the age of a given birth date in JavaScript". -+ Remember that the age also depends on the month, if the month of the current date is greater than or equal to the current month it adds up to one year". ++ Remember that the age also depends on the month, if the month of the current date is greater than or equal to the current month, it adds up one more year. + Inside your simplifier function you have to return a concatenation. From 69695ca1ecce3ee62c26805a272072b5e7d8dab9 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:46:30 +0200 Subject: [PATCH 15/94] Update README.es.md --- .../20.5-Map-arrays-of-objects/README.es.md | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/exercises/20.5-Map-arrays-of-objects/README.es.md b/exercises/20.5-Map-arrays-of-objects/README.es.md index 97bdf922..2a1c4227 100644 --- a/exercises/20.5-Map-arrays-of-objects/README.es.md +++ b/exercises/20.5-Map-arrays-of-objects/README.es.md @@ -1,4 +1,4 @@ -# `20.5` "Mapeando" un arreglo de objetos +# `20.5` Map array of objects El escenario m谩s com煤n para la funci贸n de mapeo es para simplificar los arreglos dados, por ejemplo: @@ -6,15 +6,15 @@ El algoritmo actual crea un arreglo con solo los nombres de las personas y los i ## 馃摑 Instrucciones: -1. Actualiza la funci贸n `map` para que cree un arreglo donde cada elemento contenga lo siguiente: +1. Actualiza la funci贸n `simplifier` para que cree un arreglo donde cada elemento contenga lo siguiente: -```js -Hello, my name is Joe and I am 13 years old +```text +Hello, my name is Joe and I am 36 years old ``` -##聽Resultado esperado: +##聽馃捇 Resultado esperado: -Debe quedar algo similar a esto, sin embargo las edades pueden variar. +Debe quedar algo similar a esto, sin embargo, las edades pueden variar. ```js [ 'Hello, my name is Joe and I am 36 years old', @@ -24,22 +24,12 @@ Debe quedar algo similar a esto, sin embargo las edades pueden variar. 'Hello, my name is Steve and I am 19 years old' ] ``` -## 馃挕 Pista: +## 馃挕 Pistas: + Debes determinar la edad de cada persona seg煤n su fecha de nacimiento (`birthDate`). -+ Busca en Google "C贸mo obtener la edad de la fecha de nacimiento dada en JavaScript". - -+ Recuerda la edad tambi茅n depende del mes, si el mes de la fecha actual es mayor o igual al actual suma un a帽o". ++ Busca en Google "C贸mo obtener la edad con una fecha de nacimiento dada en JavaScript". -+ Dentro de tu funci贸n simplifier, debe devolver una concatenaci贸n. ++ Recuerda la edad tambi茅n depende del d铆a, si el d铆a de la fecha actual es mayor o igual al actual se suma un a帽o. -## Resultado esperado: - -```js -[ 'Hello, my name is Joe and I am 13 years old', - 'Hello, my name is Bob and I am 42 years old', - 'Hello, my name is Erika and I am 28 years old', - 'Hello, my name is Dylan and I am 18 years old', - 'Hello, my name is Steve and I am 14 years old' ] -``` \ No newline at end of file ++ Dentro de tu funci贸n `simplifier`, debes devolver una concatenaci贸n. From cc0527247b1909a2cd04f60d3cc9d425388aa531 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:46:34 +0200 Subject: [PATCH 16/94] Update README.md --- exercises/20.5-Map-arrays-of-objects/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/20.5-Map-arrays-of-objects/README.md b/exercises/20.5-Map-arrays-of-objects/README.md index d0a456b6..634a0757 100644 --- a/exercises/20.5-Map-arrays-of-objects/README.md +++ b/exercises/20.5-Map-arrays-of-objects/README.md @@ -6,7 +6,7 @@ The current algorithm creates an array with only the names of the people and pri ## 馃摑 Instructions: -1. Please update the mapping function so it creates an array where each item contains the following: +1. Please update the `simplifier` function so it creates an array where each item contains the following: ```text Hello, my name is Joe and I am 36 years old @@ -30,6 +30,6 @@ The result should be similar to this, but the ages might be different. + Search in Google "How to get the age of a given birth date in JavaScript". -+ Remember that the age also depends on the month, if the month of the current date is greater than or equal to the current month, it adds up one more year. ++ Remember that the age also depends on the day, if the day of the current date is greater than or equal to the current day, it adds up one more year. -+ Inside your simplifier function you have to return a concatenation. ++ Inside your `simplifier` function you have to return a concatenation. From 3a15aa8807158ea9711b56431c8914b15a4c2c0e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:47:07 +0200 Subject: [PATCH 17/94] Update README.es.md --- exercises/20.5-Map-arrays-of-objects/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/20.5-Map-arrays-of-objects/README.es.md b/exercises/20.5-Map-arrays-of-objects/README.es.md index 2a1c4227..5a356500 100644 --- a/exercises/20.5-Map-arrays-of-objects/README.es.md +++ b/exercises/20.5-Map-arrays-of-objects/README.es.md @@ -12,7 +12,7 @@ El algoritmo actual crea un arreglo con solo los nombres de las personas y los i Hello, my name is Joe and I am 36 years old ``` -##聽馃捇 Resultado esperado: +## 馃捇 Resultado esperado: Debe quedar algo similar a esto, sin embargo, las edades pueden variar. From 2c3313fdd08d2681796f36a0ecb7aaf19846c5d4 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:50:24 +0200 Subject: [PATCH 18/94] Update test.js --- exercises/20.5-Map-arrays-of-objects/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/20.5-Map-arrays-of-objects/test.js b/exercises/20.5-Map-arrays-of-objects/test.js index e19d2c5e..9ca40433 100644 --- a/exercises/20.5-Map-arrays-of-objects/test.js +++ b/exercises/20.5-Map-arrays-of-objects/test.js @@ -20,7 +20,7 @@ test("You shouldn't delete the function named simplifier", function(){ }); -test('The output in the console should should look similar but not exactly (years may vary) to the one in the instructions!', function () { +test('The output in the console should look similar but not exactly (years may vary) to the one in the instructions', function () { const _app = rewire('./app.js'); let _output = [] let _people = [ From bcc6f60c1ff9d3b08df9f05599f2e91fd0f4543f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:57:27 +0200 Subject: [PATCH 19/94] Update app.js --- exercises/20.5-Map-arrays-of-objects/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/20.5-Map-arrays-of-objects/app.js b/exercises/20.5-Map-arrays-of-objects/app.js index 2c88f5ee..16f693ef 100644 --- a/exercises/20.5-Map-arrays-of-objects/app.js +++ b/exercises/20.5-Map-arrays-of-objects/app.js @@ -6,8 +6,9 @@ let people = [ { name: 'Steve', birthDate: new Date(2003,4,24) } ]; -let simplifier = function(person){ +let simplifier = function(person) { + // Your code here return person.name; }; -console.log(people.map(simplifier)); \ No newline at end of file +console.log(people.map(simplifier)); From 498710c91bc14577420dea62f342f453d87d266f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:58:03 +0200 Subject: [PATCH 20/94] Create solution.hide.js --- .../solution.hide.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 exercises/20.5-Map-arrays-of-objects/solution.hide.js diff --git a/exercises/20.5-Map-arrays-of-objects/solution.hide.js b/exercises/20.5-Map-arrays-of-objects/solution.hide.js new file mode 100644 index 00000000..ededf5c5 --- /dev/null +++ b/exercises/20.5-Map-arrays-of-objects/solution.hide.js @@ -0,0 +1,22 @@ +let people = [ + { name: 'Joe', birthDate: new Date(1986,10,24) }, + { name: 'Bob', birthDate: new Date(1975,5,24) }, + { name: 'Erika', birthDate: new Date(1989,6,12) }, + { name: 'Dylan', birthDate: new Date(1999,12,14) }, + { name: 'Steve', birthDate: new Date(2003,4,24) } +]; + +let simplifier = function(person) { + // Your code here + let currentDate = new Date(); + let age = currentDate.getFullYear() - person.birthDate.getFullYear(); + let birthDateThisYear = new Date(currentDate.getFullYear(), person.birthDate.getMonth(), person.birthDate.getDate()); + + if (currentDate < birthDateThisYear) { + age = age - 1; + } + + return `Hello, my name is ${person.name} and I am ${age} years old`; +}; + +console.log(people.map(simplifier)); From 0dae25f75ac87ec76a9b95357cf4f9b1f9688362 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 19:59:29 +0200 Subject: [PATCH 21/94] Update solution.hide.js --- exercises/20.5-Map-arrays-of-objects/solution.hide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/20.5-Map-arrays-of-objects/solution.hide.js b/exercises/20.5-Map-arrays-of-objects/solution.hide.js index ededf5c5..a0083819 100644 --- a/exercises/20.5-Map-arrays-of-objects/solution.hide.js +++ b/exercises/20.5-Map-arrays-of-objects/solution.hide.js @@ -16,7 +16,7 @@ let simplifier = function(person) { age = age - 1; } - return `Hello, my name is ${person.name} and I am ${age} years old`; + return "Hello, my name is " + person.name + " and I am " + age + " years old"; }; console.log(people.map(simplifier)); From 6491e860c87d1c0b0238849e9ee624833fb9fdca Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:06:47 +0200 Subject: [PATCH 22/94] Update README.md --- exercises/20.6-Yes-and-no/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/20.6-Yes-and-no/README.md b/exercises/20.6-Yes-and-no/README.md index 55af13dc..be1ab1f2 100644 --- a/exercises/20.6-Yes-and-no/README.md +++ b/exercises/20.6-Yes-and-no/README.md @@ -2,22 +2,22 @@ ## 馃摑 Instructions: -1. Please use the Array map functionality to loop the array of booleans and create a new array that contains the string `wiki` for every 1 and `woko` for every 0 that the original array had. +1. Use the `map()` method to loop the array of booleans and create a new array that contains the string `'wiki'` for every 1 and `'woko'` for every 0 that the given array has. -2. Print that array on the console. +2. Print the array on the console. -## 馃挕 Hint: +## 馃挕 Hints: -+ You need to map the entire array ++ You need to map the entire array. + Inside your mapping function you need to use a conditional to verify if the current value is `0` or `1`. -+ If the current value is `1` you print the string `wiki`. ++ If the current value is `1` you print the string `'wiki'`. -+ If the current value is `0` you print the string `woko`. ++ If the current value is `0` you print the string `'woko'`. -### Expected result: +## 馃捇 Expected result: ```js -[ 'woko', 'wiki', 'woko', 'woko', 'wiki', 'wiki', 'wiki', 'woko', 'woko', 'wiki', 'woko', 'wiki', 'wiki', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'wiki', 'woko', 'woko', 'woko', 'woko', 'wiki' ] -``` \ No newline at end of file +[ 'woko', 'wiki', 'woko', 'woko', 'wiki', 'wiki', 'wiki', 'woko', 'woko', 'wiki', 'woko', 'wiki', 'wiki', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'wiki', 'woko', 'woko', 'woko', 'woko', 'wiki' ] +``` From 2a95a481bcdf6d20a5c6bf163efac7c041c52384 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:06:49 +0200 Subject: [PATCH 23/94] Update README.es.md --- exercises/20.6-Yes-and-no/README.es.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/exercises/20.6-Yes-and-no/README.es.md b/exercises/20.6-Yes-and-no/README.es.md index 4b2ec2df..1635a0b1 100644 --- a/exercises/20.6-Yes-and-no/README.es.md +++ b/exercises/20.6-Yes-and-no/README.es.md @@ -1,23 +1,23 @@ -# `20.6` S铆 y no +# `20.6` Yes and No ## 馃摑 Instrucciones: -1. Por favor utiliza la funcionalidad del map para recorrer el arreglo de booleanos y crea un nuevo arreglo que contenga el string `wiki` por cada 1 y `woko` por cada 0 que tiene el arreglo original. +1. Utiliza el m茅todo `map()` para recorrer el arreglo de booleanos y crea un nuevo arreglo que contenga el string `'wiki'` por cada 1 y `'woko'` por cada 0 que tiene el arreglo dado. -2. Imprime ese arreglo en la consola. +2. Imprime el arreglo en la consola. -## 馃挕 Pista: +## 馃挕 Pistas: -+ Necesitas mapear todo el arreglo ++ Necesitas mapear todo el arreglo. + Dentro de tu funci贸n de mapeo, necesitas usar un condicional para verificar si el valor actual es `0` o `1`. -+ Si el valor actual es `1`, imprime el string `wiki`. ++ Si el valor actual es `1`, imprime el string `'wiki'`. -+ Si el valor actual es `0`, imprime el string `woko` ++ Si el valor actual es `0`, imprime el string `'woko'` -### Resultado esperado: +## 馃捇 Resultado esperado: ```js -[ 'woko', 'wiki', 'woko', 'woko', 'wiki', 'wiki', 'wiki', 'woko', 'woko', 'wiki', 'woko', 'wiki', 'wiki', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'wiki', 'woko', 'woko', 'woko', 'woko', 'wiki' ] -``` \ No newline at end of file +[ 'woko', 'wiki', 'woko', 'woko', 'wiki', 'wiki', 'wiki', 'woko', 'woko', 'wiki', 'woko', 'wiki', 'wiki', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'wiki', 'woko', 'woko', 'woko', 'woko', 'wiki' ] +``` From 9a01b9e0670cd09c999bff25cafc03d8ed4313a4 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:07:59 +0200 Subject: [PATCH 24/94] Update app.js --- exercises/20.6-Yes-and-no/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/20.6-Yes-and-no/app.js b/exercises/20.6-Yes-and-no/app.js index 50732007..cb28a338 100644 --- a/exercises/20.6-Yes-and-no/app.js +++ b/exercises/20.6-Yes-and-no/app.js @@ -1,3 +1,3 @@ -let theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1]; +let theBools = [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; -//your code here \ No newline at end of file +// Your code here From cf2a920f346aa3fb32e9276dbeb1e71dfcbe52b0 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:10:18 +0200 Subject: [PATCH 25/94] Update test.js --- exercises/20.6-Yes-and-no/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/20.6-Yes-and-no/test.js b/exercises/20.6-Yes-and-no/test.js index 860fabfb..1949de46 100644 --- a/exercises/20.6-Yes-and-no/test.js +++ b/exercises/20.6-Yes-and-no/test.js @@ -14,7 +14,7 @@ test('You have to use the console.log function to print the correct output', fun expect(console.log.mock.calls.length > 0).toBe(true); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let _output = [] let _theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1]; From c80183fc7f5e6c8b63b23a301f93cdc3d988371c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:13:35 +0200 Subject: [PATCH 26/94] Create solution.hide.js --- exercises/20.6-Yes-and-no/solution.hide.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 exercises/20.6-Yes-and-no/solution.hide.js diff --git a/exercises/20.6-Yes-and-no/solution.hide.js b/exercises/20.6-Yes-and-no/solution.hide.js new file mode 100644 index 00000000..c8c6b80b --- /dev/null +++ b/exercises/20.6-Yes-and-no/solution.hide.js @@ -0,0 +1,10 @@ +let theBools = [0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + +// Your code here + +let newArray = theBools.map(function(item) { + if (item === 0) return "woko" + else if(item === 1) return "wiki" +}) + +console.log(newArray) From 985f8623b4f383eb1a23ad5f144925fcd87fd2ef Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:31:07 +0200 Subject: [PATCH 27/94] Update README.es.md --- exercises/21-Filter-an-array/README.es.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/21-Filter-an-array/README.es.md b/exercises/21-Filter-an-array/README.es.md index 3fcb5c1d..c3eba44f 100644 --- a/exercises/21-Filter-an-array/README.es.md +++ b/exercises/21-Filter-an-array/README.es.md @@ -1,15 +1,15 @@ # `21` Filter an Array -Otra funci贸n sorprendente para los arreglos o arrays es `array.filter()` (filtrar). Recorre todo el arreglo original y solo devuelve los valores que coinciden con una condici贸n particular. +Otra funci贸n sorprendente para los arrays es `array.filter()`. Recorre todo el arreglo original y solo devuelve los valores que coinciden con una condici贸n particular. -[Aqu铆 est谩 la documentaci贸n de la funci贸n `filter` en w3school](https://www.w3schools.com/jsref/jsref_filter.asp) +[Aqu铆 est谩 la documentaci贸n de la funci贸n filter() en w3schools](https://www.w3schools.com/jsref/jsref_filter.asp) Por ejemplo, este algoritmo filtra el arreglo `allNumbers` y devuelve un nuevo arreglo con solo los n煤meros impares: ```js let allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1]; -let onlyOdds = allNumbers.filter(function(number){ +let onlyOdds = allNumbers.filter(function(number) { return (number % 2 > 0) }); @@ -24,4 +24,4 @@ console.log(onlyOdds); ## 馃挕 Pista: -+ Aqu铆 hay un video de 2:29 min explicando la [funci贸n `array.filter()`](https://www.youtube.com/watch?v=0qsFDFC2oEE9) ++ Aqu铆 hay un video de 2 min explicando la [funci贸n array.filter()](https://www.youtube.com/watch?v=0qsFDFC2oEE9). From f9986434a9e116976983372b01a75c54af86711c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:31:09 +0200 Subject: [PATCH 28/94] Update README.md --- exercises/21-Filter-an-array/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/exercises/21-Filter-an-array/README.md b/exercises/21-Filter-an-array/README.md index a2f3f46b..95cfd0b3 100644 --- a/exercises/21-Filter-an-array/README.md +++ b/exercises/21-Filter-an-array/README.md @@ -1,16 +1,15 @@ # `21` Filter an Array -Another amazing function for arrays is `array.filter()`. -It loops the entire original array and only returns the values that match a particular condition. +Another amazing function for arrays is `array.filter()`. It loops the entire original array and only returns the values that match a particular condition. -[Here is the documentation of the `filter` function in w3school](https://www.w3schools.com/jsref/jsref_filter.asp) +[Here is the documentation of the filter() function in w3schools](https://www.w3schools.com/jsref/jsref_filter.asp) For example, this algorithm filters the `allNumbers` array and returns a new array with only the odds numbers: ```js let allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1]; -let onlyOdds = allNumbers.filter(function(number){ +let onlyOdds = allNumbers.filter(function(number) { return (number % 2 > 0) }); @@ -21,8 +20,8 @@ console.log(onlyOdds); 1. Complete the code to make it fill the `resultingNames` array with only the names that start with letter R. -2. Use the `array.filter` function +2. Use the `array.filter` function. ## 馃挕 Hint: -+ Here is a 2:29 min video explaining [array.filter function](https://www.youtube.com/watch?v=0qsFDFC2oEE) \ No newline at end of file ++ Here is a 2:29 min video explaining [array.filter function](https://www.youtube.com/watch?v=0qsFDFC2oEE). From dd8d75de89f0d9e0242d91be7f8d01e500e356fa Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:31:28 +0200 Subject: [PATCH 29/94] Update README.es.md --- exercises/21-Filter-an-array/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.es.md b/exercises/21-Filter-an-array/README.es.md index c3eba44f..3978f9e9 100644 --- a/exercises/21-Filter-an-array/README.es.md +++ b/exercises/21-Filter-an-array/README.es.md @@ -2,7 +2,7 @@ Otra funci贸n sorprendente para los arrays es `array.filter()`. Recorre todo el arreglo original y solo devuelve los valores que coinciden con una condici贸n particular. -[Aqu铆 est谩 la documentaci贸n de la funci贸n filter() en w3schools](https://www.w3schools.com/jsref/jsref_filter.asp) +[Aqu铆 est谩 la documentaci贸n de la funci贸n filter() en w3schools](https://www.w3schools.com/jsref/jsref_filter.asp). Por ejemplo, este algoritmo filtra el arreglo `allNumbers` y devuelve un nuevo arreglo con solo los n煤meros impares: From 6db3bb3f731c1ba292d6c4c1d17a45fbf0361fd1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:31:34 +0200 Subject: [PATCH 30/94] Update README.md --- exercises/21-Filter-an-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.md b/exercises/21-Filter-an-array/README.md index 95cfd0b3..13164c61 100644 --- a/exercises/21-Filter-an-array/README.md +++ b/exercises/21-Filter-an-array/README.md @@ -2,7 +2,7 @@ Another amazing function for arrays is `array.filter()`. It loops the entire original array and only returns the values that match a particular condition. -[Here is the documentation of the filter() function in w3schools](https://www.w3schools.com/jsref/jsref_filter.asp) +[Here is the documentation of the filter() function in w3schools](https://www.w3schools.com/jsref/jsref_filter.asp). For example, this algorithm filters the `allNumbers` array and returns a new array with only the odds numbers: From a1cfa57a7b6f3897c547c23b9d1097de07d8dd6e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:32:12 +0200 Subject: [PATCH 31/94] Update app.js --- exercises/21-Filter-an-array/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/21-Filter-an-array/app.js b/exercises/21-Filter-an-array/app.js index c9218728..37c66dcc 100644 --- a/exercises/21-Filter-an-array/app.js +++ b/exercises/21-Filter-an-array/app.js @@ -1,5 +1,5 @@ -let allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"]; +let allNames = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "Patricia", "Danzalee"]; -//your code here +// Your code here -console.log(resultingNames); \ No newline at end of file +console.log(resultingNames); From 16e0b73622fc0105efb4fe57f80d32872df9ff6c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:32:57 +0200 Subject: [PATCH 32/94] Update test.js --- exercises/21-Filter-an-array/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/21-Filter-an-array/test.js b/exercises/21-Filter-an-array/test.js index 3ddb62f1..acf558e7 100644 --- a/exercises/21-Filter-an-array/test.js +++ b/exercises/21-Filter-an-array/test.js @@ -8,13 +8,13 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); -test("You should create the variable resultingNames.", function(){ +test("You should create the variable resultingNames", function(){ const file = rewire("./app.js"); const myVar = file.__get__('resultingNames'); expect(myVar).toBeTruthy(); }); -test('You have to use the console.log function to print the correct output.', function () { +test('You have to use the console.log function to print the correct output', function () { const app = require('./app.js'); expect(console.log.mock.calls.length > 0).toBe(true); }); @@ -25,7 +25,7 @@ test('You should use the console.log to call the variable resultingNames', funct expect(console.log).toHaveBeenCalledWith(myVar); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let _allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"]; From 044c662a64c2338295603a6d055755cfeb7737e2 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:33:54 +0200 Subject: [PATCH 33/94] Create solution.hide.js --- exercises/21-Filter-an-array/solution.hide.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 exercises/21-Filter-an-array/solution.hide.js diff --git a/exercises/21-Filter-an-array/solution.hide.js b/exercises/21-Filter-an-array/solution.hide.js new file mode 100644 index 00000000..de5a78a4 --- /dev/null +++ b/exercises/21-Filter-an-array/solution.hide.js @@ -0,0 +1,7 @@ +let allNames = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "Patricia", "Danzalee"]; + +// Your code here + +resultingNames = allNames.filter(item=>item[0] === "R") + +console.log(resultingNames); From 3744e0e7f04f0406ee8acaaa330b98b04bcf3426 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:34:23 +0200 Subject: [PATCH 34/94] Update solution.hide.js --- exercises/21-Filter-an-array/solution.hide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/solution.hide.js b/exercises/21-Filter-an-array/solution.hide.js index de5a78a4..79e587d4 100644 --- a/exercises/21-Filter-an-array/solution.hide.js +++ b/exercises/21-Filter-an-array/solution.hide.js @@ -2,6 +2,6 @@ let allNames = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "P // Your code here -resultingNames = allNames.filter(item=>item[0] === "R") +let resultingNames = allNames.filter(item=>item[0] === "R") console.log(resultingNames); From f353fe0e0f0191bd01be0e0c52f9a55896686065 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:35:51 +0200 Subject: [PATCH 35/94] Update solution.hide.js --- exercises/21-Filter-an-array/solution.hide.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/solution.hide.js b/exercises/21-Filter-an-array/solution.hide.js index 79e587d4..dd22219b 100644 --- a/exercises/21-Filter-an-array/solution.hide.js +++ b/exercises/21-Filter-an-array/solution.hide.js @@ -2,6 +2,8 @@ let allNames = ["Romario", "Boby", "Roosevelt", "Emiliy", "Michael", "Greta", "P // Your code here -let resultingNames = allNames.filter(item=>item[0] === "R") +let resultingNames = allNames.filter(function(item) { + return item[0] === "R"; +}); console.log(resultingNames); From 112bd5810054651721d0ae2a64f6b21b9f78b0df Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:39:22 +0200 Subject: [PATCH 36/94] Update README.md --- exercises/21-Filter-an-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.md b/exercises/21-Filter-an-array/README.md index 13164c61..66c34544 100644 --- a/exercises/21-Filter-an-array/README.md +++ b/exercises/21-Filter-an-array/README.md @@ -20,7 +20,7 @@ console.log(onlyOdds); 1. Complete the code to make it fill the `resultingNames` array with only the names that start with letter R. -2. Use the `array.filter` function. +2. Use the `array.filter()` function. ## 馃挕 Hint: From 9cc19d983ebe00716391193089b3e064dcd859f1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:39:59 +0200 Subject: [PATCH 37/94] Update README.md --- exercises/21-Filter-an-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.md b/exercises/21-Filter-an-array/README.md index 66c34544..d075fcbf 100644 --- a/exercises/21-Filter-an-array/README.md +++ b/exercises/21-Filter-an-array/README.md @@ -24,4 +24,4 @@ console.log(onlyOdds); ## 馃挕 Hint: -+ Here is a 2:29 min video explaining [array.filter function](https://www.youtube.com/watch?v=0qsFDFC2oEE). ++ [Here is a 2:29 min video](https://www.youtube.com/watch?v=0qsFDFC2oEE)https://www.youtube.com/watch?v=0qsFDFC2oEE explaining `array.filter()` function. From 77c8f051f50860134a9fa5f41640201ef7a98271 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:40:15 +0200 Subject: [PATCH 38/94] Update README.md --- exercises/21-Filter-an-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.md b/exercises/21-Filter-an-array/README.md index d075fcbf..cefe81f9 100644 --- a/exercises/21-Filter-an-array/README.md +++ b/exercises/21-Filter-an-array/README.md @@ -24,4 +24,4 @@ console.log(onlyOdds); ## 馃挕 Hint: -+ [Here is a 2:29 min video](https://www.youtube.com/watch?v=0qsFDFC2oEE)https://www.youtube.com/watch?v=0qsFDFC2oEE explaining `array.filter()` function. ++ [Here is a 2:29 min video](https://www.youtube.com/watch?v=0qsFDFC2oEE) explaining `array.filter()` function. From 0846b4a66c1f89e66d663d621048b4598a437a08 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:40:40 +0200 Subject: [PATCH 39/94] Update README.es.md --- exercises/21-Filter-an-array/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.es.md b/exercises/21-Filter-an-array/README.es.md index 3978f9e9..f9179e15 100644 --- a/exercises/21-Filter-an-array/README.es.md +++ b/exercises/21-Filter-an-array/README.es.md @@ -24,4 +24,4 @@ console.log(onlyOdds); ## 馃挕 Pista: -+ Aqu铆 hay un video de 2 min explicando la [funci贸n array.filter()](https://www.youtube.com/watch?v=0qsFDFC2oEE9). ++ [Aqu铆 hay un video de 2 min](https://www.youtube.com/watch?v=0qsFDFC2oEE) explicando la funci贸n `array.filter()`. From 8c92e51c042129ef095d4a28ffbc09932f8d21a2 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:41:09 +0200 Subject: [PATCH 40/94] Update README.es.md --- exercises/21-Filter-an-array/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.es.md b/exercises/21-Filter-an-array/README.es.md index f9179e15..dcaeae16 100644 --- a/exercises/21-Filter-an-array/README.es.md +++ b/exercises/21-Filter-an-array/README.es.md @@ -2,7 +2,7 @@ Otra funci贸n sorprendente para los arrays es `array.filter()`. Recorre todo el arreglo original y solo devuelve los valores que coinciden con una condici贸n particular. -[Aqu铆 est谩 la documentaci贸n de la funci贸n filter() en w3schools](https://www.w3schools.com/jsref/jsref_filter.asp). +[Aqu铆 est谩 la documentaci贸n](https://www.w3schools.com/jsref/jsref_filter.asp) de la funci贸n filter() en w3schools. Por ejemplo, este algoritmo filtra el arreglo `allNumbers` y devuelve un nuevo arreglo con solo los n煤meros impares: From 29c2d33a8eccaede7a96f4753e6a845a903288ee Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:41:23 +0200 Subject: [PATCH 41/94] Update README.es.md --- exercises/21-Filter-an-array/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.es.md b/exercises/21-Filter-an-array/README.es.md index dcaeae16..de733922 100644 --- a/exercises/21-Filter-an-array/README.es.md +++ b/exercises/21-Filter-an-array/README.es.md @@ -2,7 +2,7 @@ Otra funci贸n sorprendente para los arrays es `array.filter()`. Recorre todo el arreglo original y solo devuelve los valores que coinciden con una condici贸n particular. -[Aqu铆 est谩 la documentaci贸n](https://www.w3schools.com/jsref/jsref_filter.asp) de la funci贸n filter() en w3schools. +[Aqu铆 est谩 la documentaci贸n](https://www.w3schools.com/jsref/jsref_filter.asp) de la funci贸n `filter()` en w3schools. Por ejemplo, este algoritmo filtra el arreglo `allNumbers` y devuelve un nuevo arreglo con solo los n煤meros impares: From 9085dd1e86c3cfbdf17508ca7becdc0972ecb5b3 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:41:52 +0200 Subject: [PATCH 42/94] Update README.md --- exercises/21-Filter-an-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21-Filter-an-array/README.md b/exercises/21-Filter-an-array/README.md index cefe81f9..27030782 100644 --- a/exercises/21-Filter-an-array/README.md +++ b/exercises/21-Filter-an-array/README.md @@ -2,7 +2,7 @@ Another amazing function for arrays is `array.filter()`. It loops the entire original array and only returns the values that match a particular condition. -[Here is the documentation of the filter() function in w3schools](https://www.w3schools.com/jsref/jsref_filter.asp). +[Here is the documentation](https://www.w3schools.com/jsref/jsref_filter.asp) of the `filter()` function in w3schools. For example, this algorithm filters the `allNumbers` array and returns a new array with only the odds numbers: From e4614bb1e6fc3c4053acdbfe9f241499aba96afc Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:50:04 +0200 Subject: [PATCH 43/94] Update README.md --- exercises/21.2-Filter-done-tasks/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/exercises/21.2-Filter-done-tasks/README.md b/exercises/21.2-Filter-done-tasks/README.md index 4551abe0..67c4c885 100644 --- a/exercises/21.2-Filter-done-tasks/README.md +++ b/exercises/21.2-Filter-done-tasks/README.md @@ -2,12 +2,14 @@ ## 馃摑 Instructions: -1. Use the `filter` function to remove all the done tasks from the `tasks` array and print the new array on the console. +1. Use the `filter()` method to print in the console all the `done: true` tasks from the `tasks` array and print the new array on the console. -### Expected result: +## 馃捇 Expected result: ```js -[ { label: 'Eat my lunch', done: true }, +[ + { label: 'Eat my lunch', done: true }, { label: 'Finish my exercises', done: true }, - { label: 'Read a book', done: true } ] -``` \ No newline at end of file + { label: 'Read a book', done: true } +] +``` From 8462293d472cb2efa203c2fe850aa0ac0d82c82d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:54:38 +0200 Subject: [PATCH 44/94] Update README.es.md --- exercises/21.2-Filter-done-tasks/README.es.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/exercises/21.2-Filter-done-tasks/README.es.md b/exercises/21.2-Filter-done-tasks/README.es.md index df330db1..50230bb9 100644 --- a/exercises/21.2-Filter-done-tasks/README.es.md +++ b/exercises/21.2-Filter-done-tasks/README.es.md @@ -1,13 +1,15 @@ -# `21.2` Filtra las tareas hechas +# `21.2` Filter Done Tasks ## 馃摑 Instrucciones: -1. Usa la funci贸n `filter` para eliminar todas las tareas sin hacer del arreglo `tasks` e imprime el nuevo arreglo en la consola. +1. Usa el m茅todo `filter()` para imprimir en consola todas las tareas hechas (`done: true`) del arreglo `tasks`. -### Resultado esperado: +## 馃捇 Resultado esperado: ```js -[ { label: 'Eat my lunch', done: true }, +[ + { label: 'Eat my lunch', done: true }, { label: 'Finish my exercises', done: true }, - { label: 'Read a book', done: true } ] -``` \ No newline at end of file + { label: 'Read a book', done: true } +] +``` From 8cfa54d6a1323d3b398251c0bd764c649d04b107 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:54:44 +0200 Subject: [PATCH 45/94] Update README.md --- exercises/21.2-Filter-done-tasks/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21.2-Filter-done-tasks/README.md b/exercises/21.2-Filter-done-tasks/README.md index 67c4c885..ca2d9433 100644 --- a/exercises/21.2-Filter-done-tasks/README.md +++ b/exercises/21.2-Filter-done-tasks/README.md @@ -2,7 +2,7 @@ ## 馃摑 Instructions: -1. Use the `filter()` method to print in the console all the `done: true` tasks from the `tasks` array and print the new array on the console. +1. Use the `filter()` method to print in the console all the `done: true` tasks from the `tasks` array. ## 馃捇 Expected result: From 3cb7b9bdfd78696d3ebb623dfca0273b65303b13 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:01:00 +0200 Subject: [PATCH 46/94] Create solution.hide.js --- .../21.2-Filter-done-tasks/solution.hide.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 exercises/21.2-Filter-done-tasks/solution.hide.js diff --git a/exercises/21.2-Filter-done-tasks/solution.hide.js b/exercises/21.2-Filter-done-tasks/solution.hide.js new file mode 100644 index 00000000..a3989e74 --- /dev/null +++ b/exercises/21.2-Filter-done-tasks/solution.hide.js @@ -0,0 +1,18 @@ +let tasks = [ + { label: 'Eat my lunch', done: true }, + { label: 'Make the bed', done: false }, + { label: 'Have some fun', done: false }, + { label: 'Finish the replits', done: false }, + { label: 'Finish my exercises', done: true }, + { label: 'Ask for a raise', done: false }, + { label: 'Read a book', done: true }, + { label: 'Make a trip', done: false } +]; + +// Your code here + +let newArray = tasks.filter(function(item) { + return item.done === true; +}); + +console.log(newArray); From 5953892ccb1e304df6bad7f90e384b758a240ef1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:01:38 +0200 Subject: [PATCH 47/94] Update app.js --- exercises/21.2-Filter-done-tasks/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/21.2-Filter-done-tasks/app.js b/exercises/21.2-Filter-done-tasks/app.js index 2e7a4377..26faba34 100644 --- a/exercises/21.2-Filter-done-tasks/app.js +++ b/exercises/21.2-Filter-done-tasks/app.js @@ -3,10 +3,10 @@ let tasks = [ { label: 'Make the bed', done: false }, { label: 'Have some fun', done: false }, { label: 'Finish the replits', done: false }, - { label: 'Replit the finishes', done: true }, + { label: 'Finish my exercises', done: true }, { label: 'Ask for a raise', done: false }, { label: 'Read a book', done: true }, { label: 'Make a trip', done: false } ]; -//your code here \ No newline at end of file +// Your code here From a05819e0627389dda78d7438012e792bf56a7510 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:02:15 +0200 Subject: [PATCH 48/94] Update test.js --- exercises/21.2-Filter-done-tasks/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/21.2-Filter-done-tasks/test.js b/exercises/21.2-Filter-done-tasks/test.js index 7e753abd..d86229b6 100644 --- a/exercises/21.2-Filter-done-tasks/test.js +++ b/exercises/21.2-Filter-done-tasks/test.js @@ -8,12 +8,12 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); -test('You have to use the console.log function to print the correct output.', function () { +test('You have to use the console.log function to print the correct output', function () { const app = require('./app.js'); expect(console.log.mock.calls.length > 0).toBe(true); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let _tasks = [ { label: 'Eat my lunch', done: true }, From 9d0490061d1d751783d7e427bd9ee234da747b7d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:06:17 +0200 Subject: [PATCH 49/94] Update README.md --- exercises/21.3-Filter-list/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/21.3-Filter-list/README.md b/exercises/21.3-Filter-list/README.md index 276fab4f..b3f54ef8 100644 --- a/exercises/21.3-Filter-list/README.md +++ b/exercises/21.3-Filter-list/README.md @@ -4,14 +4,14 @@ Given an array `names`, please create a function that filters only the names containing the given string. -1. Create a function called `filterByName` that accepts two values one is the array and the second one is the filter desire. +1. Create a function called `filterByName` that accepts two values, one is the array, and the second one is the filter criteria. **The search should NOT be Case Sensitive.** ## 馃挕 Hint: ```js - // Use any of the built in methods + // Use any of the built-in methods array.push(); array.filter(); From 5535d60098f89e02079c8c74de608ad8a79bf5ba Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:09:28 +0200 Subject: [PATCH 50/94] Update README.es.md --- exercises/21.3-Filter-list/README.es.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exercises/21.3-Filter-list/README.es.md b/exercises/21.3-Filter-list/README.es.md index b2277237..c256c433 100644 --- a/exercises/21.3-Filter-list/README.es.md +++ b/exercises/21.3-Filter-list/README.es.md @@ -1,14 +1,13 @@ # `21.3` Filtrar un arreglo de strings -## Instrucciones: +## 馃摑 Instrucciones: -Dados los nombres del arreglo `names`, crea una funci贸n `filter` que liste solo los nombres que contengan el string dado. +Dados los nombres del arreglo `names`, crea una funci贸n que liste solo los nombres que contengan el string dado. -1. Crea una funci贸n llamada `filterByName` que tome dos valores, uno es al arreglo y el segundo es el filtro deseado. +1. Crea una funci贸n llamada `filterByName` que tome dos valores, uno es el arreglo, y el segundo es el filtro deseado. **La b煤squeda NO debe ser sensible a may煤sculas y min煤sculas (case sensitive).** - ## 馃挕 Pista: ```js @@ -18,4 +17,4 @@ Dados los nombres del arreglo `names`, crea una funci贸n `filter` que liste solo array.filter(); string.includes(); string.toLowerCase(); -``` \ No newline at end of file +``` From 1080e4a9880fce170f02187516dc08218b9cfd45 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:09:41 +0200 Subject: [PATCH 51/94] Update README.md From 9a05dfd3aca644a98945f9dcc0dafdc9581e3335 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:10:16 +0200 Subject: [PATCH 52/94] Update test.js --- exercises/21.3-Filter-list/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/21.3-Filter-list/test.js b/exercises/21.3-Filter-list/test.js index 76ee64d4..95c6ee8e 100644 --- a/exercises/21.3-Filter-list/test.js +++ b/exercises/21.3-Filter-list/test.js @@ -14,12 +14,12 @@ test("You should create a function named filterByName", function(){ expect(myFunc).toBeTruthy(); }); -test('You have to use the console.log function to print the correct output.', function () { +test('You have to use the console.log function to print the correct output', function () { const app = require('./app.js'); expect(console.log.mock.calls.length > 0).toBe(true); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let _names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley']; From 24db0abc36f400e85ae8d90e314699bcd34e54ea Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:15:04 +0200 Subject: [PATCH 53/94] Create solution.hide.js --- exercises/21.3-Filter-list/solution.hide.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 exercises/21.3-Filter-list/solution.hide.js diff --git a/exercises/21.3-Filter-list/solution.hide.js b/exercises/21.3-Filter-list/solution.hide.js new file mode 100644 index 00000000..3c374619 --- /dev/null +++ b/exercises/21.3-Filter-list/solution.hide.js @@ -0,0 +1,10 @@ +let names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley']; + +// Your code here + +function filterByName(array, filterString) { + let filteredArray = array.filter(item => item.toLowerCase().includes(filterString.toLowerCase())) + return filteredArray +} + +console.log(filterByName(names, 'am')); From 09d51235b2e272fe8df0091eb92a9d276b64c5eb Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:15:18 +0200 Subject: [PATCH 54/94] Update app.js --- exercises/21.3-Filter-list/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/21.3-Filter-list/app.js b/exercises/21.3-Filter-list/app.js index 57ec4ce7..aaf455ca 100644 --- a/exercises/21.3-Filter-list/app.js +++ b/exercises/21.3-Filter-list/app.js @@ -1,5 +1,5 @@ let names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley']; -//declare your function here +// Your code here -console.log(filterByName(names, 'am')); \ No newline at end of file +console.log(filterByName(names, 'am')); From b73686aedd435f6dfb8991790d33cba30812fded Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:15:35 +0200 Subject: [PATCH 55/94] Update solution.hide.js --- exercises/21.3-Filter-list/solution.hide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21.3-Filter-list/solution.hide.js b/exercises/21.3-Filter-list/solution.hide.js index 3c374619..09c7e0b1 100644 --- a/exercises/21.3-Filter-list/solution.hide.js +++ b/exercises/21.3-Filter-list/solution.hide.js @@ -4,7 +4,7 @@ let names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','L function filterByName(array, filterString) { let filteredArray = array.filter(item => item.toLowerCase().includes(filterString.toLowerCase())) - return filteredArray + return filteredArray; } console.log(filterByName(names, 'am')); From 84052e0f94a8e4cbd86258fb3188aee9f2c3cd9d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:18:14 +0200 Subject: [PATCH 56/94] Update README.md --- exercises/21.3-Filter-list/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises/21.3-Filter-list/README.md b/exercises/21.3-Filter-list/README.md index b3f54ef8..f65a4622 100644 --- a/exercises/21.3-Filter-list/README.md +++ b/exercises/21.3-Filter-list/README.md @@ -8,6 +8,12 @@ Given an array `names`, please create a function that filters only the names con **The search should NOT be Case Sensitive.** +## 馃捇 Expected result: + +```js +[ 'Liam', 'William', 'James', 'Benjamin', 'Amelia', 'Samuel', 'Camila' ] +``` + ## 馃挕 Hint: ```js From 3b21d81b9b57fbbb105f83128b8c3de0812b2b54 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:19:58 +0200 Subject: [PATCH 57/94] Update README.es.md --- exercises/21.3-Filter-list/README.es.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises/21.3-Filter-list/README.es.md b/exercises/21.3-Filter-list/README.es.md index c256c433..018cfc94 100644 --- a/exercises/21.3-Filter-list/README.es.md +++ b/exercises/21.3-Filter-list/README.es.md @@ -8,6 +8,12 @@ Dados los nombres del arreglo `names`, crea una funci贸n que liste solo los nomb **La b煤squeda NO debe ser sensible a may煤sculas y min煤sculas (case sensitive).** +## 馃捇 Resultado esperado: + +```js +[ 'Liam', 'William', 'James', 'Benjamin', 'Amelia', 'Samuel', 'Camila' ] +``` + ## 馃挕 Pista: ```js From 427282488800c8be295aa4565105155c884b372a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:20:29 +0200 Subject: [PATCH 58/94] Update solution.hide.js --- exercises/21.3-Filter-list/solution.hide.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/21.3-Filter-list/solution.hide.js b/exercises/21.3-Filter-list/solution.hide.js index 09c7e0b1..c2416eed 100644 --- a/exercises/21.3-Filter-list/solution.hide.js +++ b/exercises/21.3-Filter-list/solution.hide.js @@ -3,8 +3,8 @@ let names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','L // Your code here function filterByName(array, filterString) { - let filteredArray = array.filter(item => item.toLowerCase().includes(filterString.toLowerCase())) - return filteredArray; + let filteredNames = array.filter(item => item.toLowerCase().includes(filterString.toLowerCase())) + return filteredNames; } console.log(filterByName(names, 'am')); From 68fe58cd29ea936d0019580e85610fa8086ff3b7 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:20:39 +0200 Subject: [PATCH 59/94] Update solution.hide.js --- exercises/21.3-Filter-list/solution.hide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21.3-Filter-list/solution.hide.js b/exercises/21.3-Filter-list/solution.hide.js index c2416eed..23a64d36 100644 --- a/exercises/21.3-Filter-list/solution.hide.js +++ b/exercises/21.3-Filter-list/solution.hide.js @@ -3,7 +3,7 @@ let names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','L // Your code here function filterByName(array, filterString) { - let filteredNames = array.filter(item => item.toLowerCase().includes(filterString.toLowerCase())) + let filteredNames = array.filter(item => item.toLowerCase().includes(filterString.toLowerCase())); return filteredNames; } From 59ff16f4999b043beb4f2537d9a19b2deb445d6b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:28:06 +0200 Subject: [PATCH 60/94] Update README.es.md --- exercises/22-Matrix-Builder/README.es.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exercises/22-Matrix-Builder/README.es.md b/exercises/22-Matrix-Builder/README.es.md index b4873c41..47c11700 100644 --- a/exercises/22-Matrix-Builder/README.es.md +++ b/exercises/22-Matrix-Builder/README.es.md @@ -2,13 +2,15 @@ Reconstruyendo coaliciones en la Matrix -Despu茅s de un c贸digo malicioso, creado principalmente por el Sr. Smith, la matrix tiene un hueco enorme y necesita ayuda para reconstruirse. Crea una arreglo/matriz con 0s y 1s aleatorios basado en un par谩metro. +Despu茅s de un c贸digo malicioso, creado principalmente por el Sr. Smith, la matrix tiene un hueco enorme y necesita ayuda para reconstruirse. Crea un arreglo/matriz con 0s y 1s aleatorios basado en un par谩metro. ## 馃摑 Instrucciones: -1. Crea una funci贸n llamada `matrixBuilder`, que esperar谩 1 par谩metro (un entero). Este n煤mero representa la cantidad de filas y columnas para la matriz. Ejemplo: 5 significa que la matriz debe ser `5 x 5`. +1. Crea una funci贸n llamada `matrixBuilder`, que esperar谩 1 par谩metro (un entero). Este n煤mero representa la cantidad de filas y columnas para la matriz. -2. Esta funci贸n deber铆a devolver un arreglo con arreglos que representa la matriz. Ejemplo: 3 deber铆a devolver: +> Ejemplo: 5 significa que la matriz debe ser `5 x 5`. + +2. Esta funci贸n deber铆a devolver un arreglo con arreglos que representa la matriz. **Ejemplo:** con 3 como argumento deber铆a devolver: ```js [ @@ -18,4 +20,4 @@ Despu茅s de un c贸digo malicioso, creado principalmente por el Sr. Smith, la mat ] ``` -**Recuerde que los 1s y 0s son aleatorios.** \ No newline at end of file +**Recuerde que los 1s y 0s son aleatorios.** From 24bdf8ef93718d1d03ee5855b37ac1388291bf03 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:28:08 +0200 Subject: [PATCH 61/94] Update README.md --- exercises/22-Matrix-Builder/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exercises/22-Matrix-Builder/README.md b/exercises/22-Matrix-Builder/README.md index b2b18a4d..555425a1 100644 --- a/exercises/22-Matrix-Builder/README.md +++ b/exercises/22-Matrix-Builder/README.md @@ -6,12 +6,11 @@ After some malicious code, mainly by Mr. Smith, the matrix has some gaping hole ## 馃摑 Instructions: -1. Create a function called `matrixBuilder`, which will expect 1 parameter (an integer). -This number represents the amount of rows and columns for the matrix. +1. Create a function called `matrixBuilder`, which will expect 1 parameter (an integer). This number represents the amount of rows and columns for the matrix. -Example: 5 means that the matrix should be `5 x 5`. +> Example: 5 means that the matrix should be `5 x 5`. -2. This function should return an array of arrays that represents the matrix. Example: 3 should return: +2. This function should return an array of arrays that represents the matrix. **Example:** with 3 as an argument it should return: ```js [ @@ -21,4 +20,4 @@ Example: 5 means that the matrix should be `5 x 5`. ] ``` -**Remember that 0's and 1's must be random.** \ No newline at end of file +**Remember that 0's and 1's must be random.** From 8c0aac676bad5b24a8a96f45b833f0fc10dba325 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:30:32 +0200 Subject: [PATCH 62/94] Update README.md --- exercises/22-Matrix-Builder/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/22-Matrix-Builder/README.md b/exercises/22-Matrix-Builder/README.md index 555425a1..b9e7a24a 100644 --- a/exercises/22-Matrix-Builder/README.md +++ b/exercises/22-Matrix-Builder/README.md @@ -2,7 +2,7 @@ Matrix Rebuilding Coalitions -After some malicious code, mainly by Mr. Smith, the matrix has some gaping hole and it needs some help to rebuild. Create a matrix of random 0's and 1's based on a parameter. +After some malicious code, mainly created by Mr. Smith, the matrix has a gaping hole, and needs some help to rebuild. Create a matrix of random 0's and 1's based on a parameter. ## 馃摑 Instructions: From 10e5a9923d8fd8256e29794317cf6d979d2c379d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:30:53 +0200 Subject: [PATCH 63/94] Update README.md --- exercises/22-Matrix-Builder/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/22-Matrix-Builder/README.md b/exercises/22-Matrix-Builder/README.md index b9e7a24a..dafc6af2 100644 --- a/exercises/22-Matrix-Builder/README.md +++ b/exercises/22-Matrix-Builder/README.md @@ -2,7 +2,7 @@ Matrix Rebuilding Coalitions -After some malicious code, mainly created by Mr. Smith, the matrix has a gaping hole, and needs some help to rebuild. Create a matrix of random 0's and 1's based on a parameter. +After some malicious code, mainly created by Mr. Smith, the matrix has a gaping hole, and it needs some help to rebuild. Create a matrix of random 0's and 1's based on a parameter. ## 馃摑 Instructions: From c6dc84b8c18f2ee7e9a9e61273930d3e9255b212 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:31:21 +0200 Subject: [PATCH 64/94] Update README.md --- exercises/22-Matrix-Builder/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/22-Matrix-Builder/README.md b/exercises/22-Matrix-Builder/README.md index dafc6af2..98b925bb 100644 --- a/exercises/22-Matrix-Builder/README.md +++ b/exercises/22-Matrix-Builder/README.md @@ -10,7 +10,7 @@ After some malicious code, mainly created by Mr. Smith, the matrix has a gaping > Example: 5 means that the matrix should be `5 x 5`. -2. This function should return an array of arrays that represents the matrix. **Example:** with 3 as an argument it should return: +2. This function should return an array of arrays that represent the matrix. **Example:** with 3 as an argument it should return: ```js [ From 40f606a9930bd701e6ec5b02725c9f8d434bd888 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:31:54 +0200 Subject: [PATCH 65/94] Update app.js --- exercises/22-Matrix-Builder/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/22-Matrix-Builder/app.js b/exercises/22-Matrix-Builder/app.js index e918f509..93d285e4 100644 --- a/exercises/22-Matrix-Builder/app.js +++ b/exercises/22-Matrix-Builder/app.js @@ -1,6 +1,6 @@ -// Code goes here +// Your code here -// do not change anything from this line down -console.log(matrixBuilder(5)) \ No newline at end of file +// Do not change anything from this line down +console.log(matrixBuilder(5)) From 73b3223160a854bef567647da0f528638f4c5961 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:32:23 +0200 Subject: [PATCH 66/94] Update test.js --- exercises/22-Matrix-Builder/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/22-Matrix-Builder/test.js b/exercises/22-Matrix-Builder/test.js index 12952f3f..90f16157 100644 --- a/exercises/22-Matrix-Builder/test.js +++ b/exercises/22-Matrix-Builder/test.js @@ -8,13 +8,13 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); -test("You should create a function named matrixBuilder.", function(){ +test("You should create a function named matrixBuilder", function(){ const file = rewire("./app.js"); const myFunc = file.__get__('matrixBuilder'); expect(myFunc).toBeTruthy(); }); -test('The matrix should have the ammount of rows and columns required as parameter.', function () { +test('The matrix should have the ammount of rows and columns required as parameter', function () { const file = rewire("./app.js"); const myFunc = file.__get__('matrixBuilder'); @@ -23,7 +23,7 @@ test('The matrix should have the ammount of rows and columns required as paramet expect(_test[0].length.toString()).toMatch("5"); }); -test('The matrix should only have 0 or 1 as values.', function(){ +test('The matrix should only have 0 or 1 as values', function(){ const file = rewire("./app.js"); const myFunc = file.__get__('matrixBuilder'); let _test = myFunc(5); From 527d4205457745f0078deaa1c379337d6130ed68 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:37:15 +0200 Subject: [PATCH 67/94] Create solution.hide.js --- exercises/22-Matrix-Builder/solution.hide.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 exercises/22-Matrix-Builder/solution.hide.js diff --git a/exercises/22-Matrix-Builder/solution.hide.js b/exercises/22-Matrix-Builder/solution.hide.js new file mode 100644 index 00000000..df733eb9 --- /dev/null +++ b/exercises/22-Matrix-Builder/solution.hide.js @@ -0,0 +1,20 @@ +// Your code here +function matrixBuilder(n) { + let matrix = []; + + for (let i = 0; i < n; i++) { + let row = []; + + for (let j = 0; j < n; j++) { + let randomValue = Math.floor(Math.random() + 0.5); + row.push(randomValue); + } + + matrix.push(row); + } + + return matrix; + } + +// Do not change anything from this line down +console.log(matrixBuilder(5)) From 427829d65fd5575e6484765a0c9fda1f2d176556 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:43:14 +0200 Subject: [PATCH 68/94] Update README.md --- exercises/23-Parking-Lot/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/23-Parking-Lot/README.md b/exercises/23-Parking-Lot/README.md index 0fae1c07..794aa5b1 100644 --- a/exercises/23-Parking-Lot/README.md +++ b/exercises/23-Parking-Lot/README.md @@ -6,7 +6,7 @@ We can use a 2 dimensional array (matrix) to represent the current state of a pa ![Parking Lot BreatheCode](../../.learn/assets/23.png) ```js -parking_state = [ +parkingState = [ [1,0,1,1,0,1], [2,0,1,1,0,1], [1,0,2,1,0,1], @@ -28,4 +28,4 @@ const state = { ``` ## 馃挕 Hint: -+ You have to do a nested loop ++ You have to do a nested loop. From 99e550995a043e73e303eceb245ea2018b5727a2 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:45:26 +0200 Subject: [PATCH 69/94] Update README.es.md --- exercises/23-Parking-Lot/README.es.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exercises/23-Parking-Lot/README.es.md b/exercises/23-Parking-Lot/README.es.md index 0ce4c3d7..8661f2de 100644 --- a/exercises/23-Parking-Lot/README.es.md +++ b/exercises/23-Parking-Lot/README.es.md @@ -1,12 +1,11 @@ -# `23` Estacionamiento (Parking lot) +# `23` Parking lot Podemos usar un arreglo bidimensional (matriz) para representar el estado actual de un estacionamiento as铆: - ![Parking Lot BreatheCode](../../.learn/assets/23.png) ```js -parking_state = [ +parkingState = [ [1,0,1,1,0,1], [2,0,1,1,0,1], [1,0,2,1,0,1], @@ -18,7 +17,7 @@ parking_state = [ ## 馃摑 Instrucciones: -1. Crea una funci贸n `getParkingLotState()` que devuelva un objeto con `totalSlots` (cantidad total de estacionamientos), `availableSlots` (estacionamientos disponibles) y `occupiedSlots` (estacionamientos ocupados) de esta forma: +1. Crea una funci贸n `getParkingLotState()` que devuelva un objeto con `totalSlots` (cantidad total de puestos), `availableSlots` (puestos disponibles) y `occupiedSlots` (puestos ocupados) de esta forma: ```js const state = { @@ -30,4 +29,4 @@ const state = { ## 馃挕 Pista: -+ Tienes que hacer un bucle anidado ++ Tienes que hacer un bucle anidado. From d49e36bff4c5eff0451c52e330ede4e949ca1ac5 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:49:29 +0200 Subject: [PATCH 70/94] Update app.js --- exercises/23-Parking-Lot/app.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/exercises/23-Parking-Lot/app.js b/exercises/23-Parking-Lot/app.js index 80514a37..3add6b83 100644 --- a/exercises/23-Parking-Lot/app.js +++ b/exercises/23-Parking-Lot/app.js @@ -1,6 +1,4 @@ - - -let parking_state = [ +let parkingState = [ [1, 0, 1, 1], [0, 0, 0, 2], [1, 1, 2, 1], @@ -10,4 +8,4 @@ let parking_state = [ // Your code here -console.log(getParkingLotState(parking_state)) \ No newline at end of file +console.log(getParkingLotState(parking_state)) From a75f40c8ba61b25dd07268463ccd89be4d3fc612 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:51:23 +0200 Subject: [PATCH 71/94] Update README.md --- exercises/23-Parking-Lot/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/23-Parking-Lot/README.md b/exercises/23-Parking-Lot/README.md index 794aa5b1..7b49884e 100644 --- a/exercises/23-Parking-Lot/README.md +++ b/exercises/23-Parking-Lot/README.md @@ -20,7 +20,7 @@ parkingState = [ 1. Create a function `getParkingLotState()` that returns an object with `totalSlots`, `availableSlots` and `occupiedSlots` like the following: ```js -const state = { +let state = { totalSlots: 12, availableSlots: 3, occupiedSlots: 9 From 6e70ff1082ed790b1584ee1d3b066bc4473ece7b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:51:29 +0200 Subject: [PATCH 72/94] Update README.es.md --- exercises/23-Parking-Lot/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/23-Parking-Lot/README.es.md b/exercises/23-Parking-Lot/README.es.md index 8661f2de..581b95e6 100644 --- a/exercises/23-Parking-Lot/README.es.md +++ b/exercises/23-Parking-Lot/README.es.md @@ -20,7 +20,7 @@ parkingState = [ 1. Crea una funci贸n `getParkingLotState()` que devuelva un objeto con `totalSlots` (cantidad total de puestos), `availableSlots` (puestos disponibles) y `occupiedSlots` (puestos ocupados) de esta forma: ```js -const state = { +let state = { totalSlots: 12, availableSlots: 3, occupiedSlots: 9 From a2371b0a9e8b6978362e609996e0805dfd7e18a7 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:52:18 +0200 Subject: [PATCH 73/94] Update README.es.md --- exercises/23-Parking-Lot/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/23-Parking-Lot/README.es.md b/exercises/23-Parking-Lot/README.es.md index 581b95e6..5ecc1dee 100644 --- a/exercises/23-Parking-Lot/README.es.md +++ b/exercises/23-Parking-Lot/README.es.md @@ -5,7 +5,7 @@ Podemos usar un arreglo bidimensional (matriz) para representar el estado actual ![Parking Lot BreatheCode](../../.learn/assets/23.png) ```js -parkingState = [ +let parkingState = [ [1,0,1,1,0,1], [2,0,1,1,0,1], [1,0,2,1,0,1], From 04fe5b3130f0f797111db1b3f3bf8e9c006ab994 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:52:21 +0200 Subject: [PATCH 74/94] Update README.md --- exercises/23-Parking-Lot/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/23-Parking-Lot/README.md b/exercises/23-Parking-Lot/README.md index 7b49884e..3a612c32 100644 --- a/exercises/23-Parking-Lot/README.md +++ b/exercises/23-Parking-Lot/README.md @@ -6,7 +6,7 @@ We can use a 2 dimensional array (matrix) to represent the current state of a pa ![Parking Lot BreatheCode](../../.learn/assets/23.png) ```js -parkingState = [ +let parkingState = [ [1,0,1,1,0,1], [2,0,1,1,0,1], [1,0,2,1,0,1], From aa7659ed9b2f64dc80c5555b038b486f27264e9e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:52:46 +0200 Subject: [PATCH 75/94] Update app.js --- exercises/23-Parking-Lot/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/23-Parking-Lot/app.js b/exercises/23-Parking-Lot/app.js index 3add6b83..f9b3c27c 100644 --- a/exercises/23-Parking-Lot/app.js +++ b/exercises/23-Parking-Lot/app.js @@ -8,4 +8,4 @@ let parkingState = [ // Your code here -console.log(getParkingLotState(parking_state)) +console.log(getParkingLotState(parkingState)) From 33cead3793f7133b15f040f430ab198f67b31346 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:56:22 +0200 Subject: [PATCH 76/94] Update solution.hide.js --- exercises/23-Parking-Lot/solution.hide.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/exercises/23-Parking-Lot/solution.hide.js b/exercises/23-Parking-Lot/solution.hide.js index 1b25e298..4e7ded96 100644 --- a/exercises/23-Parking-Lot/solution.hide.js +++ b/exercises/23-Parking-Lot/solution.hide.js @@ -1,18 +1,25 @@ +let parkingState = [ + [1, 0, 1, 1], + [0, 0, 0, 2], + [1, 1, 2, 1], + [2, 1, 1, 1] +] + // Your code here -function getParkingLotState(param) { +function getParkingLotState(parkingArray) { let state = { totalSlots: 0, availableSlots: 0, occupiedSlots: 0 } - for (let i = 0; i < param.length; i++) { - for (let x = 0; x < param[i].length; x++) { - if (param[i][x] === 2) { + for (let i = 0; i < parkingArray.length; i++) { + for (let x = 0; x < parkingArray[i].length; x++) { + if (parkingArray[i][x] === 2) { state.availableSlots += 1 state.totalSlots += 1 } - else if (param[i][x] === 1) { + else if (parkingArray[i][x] === 1) { state.occupiedSlots += 1 state.totalSlots += 1 } @@ -20,3 +27,5 @@ function getParkingLotState(param) { } return state } + +console.log(getParkingLotState(parkingState)); From ba2dfd4b29f250f33b8d2d8a66c113dbb481c94d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:57:12 +0200 Subject: [PATCH 77/94] Update test.js --- exercises/23-Parking-Lot/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/23-Parking-Lot/test.js b/exercises/23-Parking-Lot/test.js index 87b99f45..bc44f2d7 100644 --- a/exercises/23-Parking-Lot/test.js +++ b/exercises/23-Parking-Lot/test.js @@ -18,12 +18,12 @@ test("The function should return something", function () { expect(getParkingLotState([])).toBeTruthy(); }); -test('You have to use the console.log function to print the correct output.', function () { +test('You have to use the console.log function to print the correct output', function () { const app = require('./app.js'); expect(console.log.mock.calls.length > 0).toBe(true); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let _parking_state = [ [1,0,1,1], From 43c6678347076e960025259a6bbd663c41dcd6e5 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:04:51 +0200 Subject: [PATCH 78/94] Update README.es.md --- exercises/24-Making-a-ul/README.es.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/24-Making-a-ul/README.es.md b/exercises/24-Making-a-ul/README.es.md index 1d2ef98d..55949b2b 100644 --- a/exercises/24-Making-a-ul/README.es.md +++ b/exercises/24-Making-a-ul/README.es.md @@ -1,9 +1,9 @@ -# `24` Haz una UL +# `24` Making a UL ## 馃摑 Instrucciones: 1. Rellena la funci贸n `generateLI` y `filterColors` para que el ejercicio imprima el siguiente HTML con solo los colores sexys. As铆: -```js +```html -``` \ No newline at end of file +``` From 4f2389cdaf43794ce70f36d67cb091e6024631d8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:04:54 +0200 Subject: [PATCH 79/94] Update README.md --- exercises/24-Making-a-ul/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/24-Making-a-ul/README.md b/exercises/24-Making-a-ul/README.md index 8fa4e047..cdd13725 100644 --- a/exercises/24-Making-a-ul/README.md +++ b/exercises/24-Making-a-ul/README.md @@ -4,6 +4,6 @@ - Fill the `generateLI` and `filterColors` function to make the exercise print the following HTML with only the sexy colors. Like this: -```js +```html -``` \ No newline at end of file +``` From 34fb7ab368a3e4db3bf1f37bfbc473b3ee4644c8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:24:02 +0200 Subject: [PATCH 80/94] Update README.md --- exercises/24-Making-a-ul/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/24-Making-a-ul/README.md b/exercises/24-Making-a-ul/README.md index cdd13725..b15321b7 100644 --- a/exercises/24-Making-a-ul/README.md +++ b/exercises/24-Making-a-ul/README.md @@ -2,7 +2,9 @@ ## 馃摑 Instructions: -- Fill the `generateLI` and `filterColors` function to make the exercise print the following HTML with only the sexy colors. Like this: +1. Fill the `generateLI` and `filterColors` functions to make the exercise print the following HTML with only the sexy colors. + +## 馃捇 Expected result: ```html From d8aed0a1a3d8cfc2fe5b67548f95ecc66a2e5f9a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:25:00 +0200 Subject: [PATCH 81/94] Update README.es.md --- exercises/24-Making-a-ul/README.es.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/24-Making-a-ul/README.es.md b/exercises/24-Making-a-ul/README.es.md index 55949b2b..2ff20a23 100644 --- a/exercises/24-Making-a-ul/README.es.md +++ b/exercises/24-Making-a-ul/README.es.md @@ -2,7 +2,9 @@ ## 馃摑 Instrucciones: -1. Rellena la funci贸n `generateLI` y `filterColors` para que el ejercicio imprima el siguiente HTML con solo los colores sexys. As铆: +1. Rellena las funciones `generateLI` y `filterColors` para que el ejercicio imprima el siguiente HTML con solo los colores sexys. + +## 馃捇 Resultado esperado: ```html From 0954c20bb33b9dbf7b98c62596a4962100167ec1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:25:33 +0200 Subject: [PATCH 82/94] Update README.es.md --- exercises/21.3-Filter-list/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/21.3-Filter-list/README.es.md b/exercises/21.3-Filter-list/README.es.md index 018cfc94..9cf67a6d 100644 --- a/exercises/21.3-Filter-list/README.es.md +++ b/exercises/21.3-Filter-list/README.es.md @@ -1,4 +1,4 @@ -# `21.3` Filtrar un arreglo de strings +# `21.3` Filter Array of Strings ## 馃摑 Instrucciones: From 52c2d95fb3e76319a34316582dec0d2c4f104a36 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:27:07 +0200 Subject: [PATCH 83/94] Create solution.hide.js --- exercises/24-Making-a-ul/solution.hide.js | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 exercises/24-Making-a-ul/solution.hide.js diff --git a/exercises/24-Making-a-ul/solution.hide.js b/exercises/24-Making-a-ul/solution.hide.js new file mode 100644 index 00000000..403c8b0d --- /dev/null +++ b/exercises/24-Making-a-ul/solution.hide.js @@ -0,0 +1,34 @@ +let allColors = [ + {label: 'Red', sexy: true}, + {label: 'Pink', sexy: false}, + {label: 'Orange', sexy: true}, + {label: 'Brown', sexy: false}, + {label: 'Pink', sexy: true}, + {label: 'Violet', sexy: true}, + {label: 'Purple', sexy: false}, +]; + +function generateLI(color) { + // Your code here + return `
  • ${color.label}
  • `; +} + +function filterColors(color) { + // Your code here + return color.sexy === true; +} + +function generateHTMLFromArray(array) { + + let filteredOptions = array.filter((filterColors)); + let LIs = filteredOptions.map(generateLI); + + let htmlString = ''; + return htmlString; +} + +console.log(generateHTMLFromArray(allColors)); From 4bfa5701b1c7d5d5e66fc8522e480271c70bf1ca Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:29:36 +0200 Subject: [PATCH 84/94] Update app.js --- exercises/24-Making-a-ul/app.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/exercises/24-Making-a-ul/app.js b/exercises/24-Making-a-ul/app.js index 0f917af7..440079e8 100644 --- a/exercises/24-Making-a-ul/app.js +++ b/exercises/24-Making-a-ul/app.js @@ -8,26 +8,25 @@ let allColors = [ {label: 'Purple', sexy: false}, ]; -function generateLI(color){ - // your code here +function generateLI(color) { + // Your code here } -function filterColors(color){ - // your code here +function filterColors(color) { + // Your code here } -function generateHTMLFromArray(array){ +function generateHTMLFromArray(array) { - let filteredOptions = array.filter(filterColors); + let filteredOptions = array.filter((filterColors)); let LIs = filteredOptions.map(generateLI); let htmlString = ''; return htmlString; } console.log(generateHTMLFromArray(allColors)); - From 349becb02cff75d4f05a84d4d744981db30fa9f8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:38:04 +0200 Subject: [PATCH 85/94] Update test.js --- exercises/24-Making-a-ul/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/24-Making-a-ul/test.js b/exercises/24-Making-a-ul/test.js index 7c36d2d2..7e91859a 100644 --- a/exercises/24-Making-a-ul/test.js +++ b/exercises/24-Making-a-ul/test.js @@ -24,12 +24,12 @@ test("The function named generateHTMLFromArray should exist", function(){ expect(myFunc).toBeTruthy(); }); -test('You have to use the console.log function to print the correct output.', function () { +test('You have to use the console.log function to print the correct output', function () { const app = require('./app.js'); expect(console.log.mock.calls.length > 0).toBe(true); }); -test('The output in the console should match the one in the instructions!', function () { +test('The output in the console should match the one in the instructions', function () { const _app = rewire('./app.js'); let allColors = [ From de8828cfcca1e7bd74eebc0db1571b74588ad926 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:48:20 +0200 Subject: [PATCH 86/94] Update README.md --- exercises/25-Techno-beat/README.md | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/exercises/25-Techno-beat/README.md b/exercises/25-Techno-beat/README.md index 53dca14f..22c248b1 100644 --- a/exercises/25-Techno-beat/README.md +++ b/exercises/25-Techno-beat/README.md @@ -1,37 +1,33 @@ # `25` Techno Beats -You are working with a DJ and he needs a program that can create a beats for his song. +You are working with a DJ, and he needs a program that can create beats for his song. ## 馃摑 Instructions: 1. Create a function `lyricsGenerator` that receives an array. The array passed to the function will be something like this: + ```js [0,0,1,1,0,0,0] ``` -2. For each Zero you will add to the string 'Boom' -3. For each One you will add to the string 'Drop the base' +2. For each `0` you will add to the string `'Boom'`. -### Constraints: +3. For each `1` you will add to the string `'Drop the bass'`. -+ If you find the number One (1) three times in a row, you should ALSO ADD to the string `!!!Break the base!!!` +4. If you find the number `1` three times in a row, you should ALSO ADD to the string `!!!Break the bass!!!`. -### Expected Function Output: - -A string which should be comprise of Boom or Drop the base or `!!!Break the base!!!` - -### Expected Output: +## 馃捇 Expected Output: ```js -Boom Boom Drop the base Drop the base Boom Boom Boom -Boom Boom Drop the base Drop the base Drop the base !!!Break the base!!! Boom Boom Boom +Boom Boom Drop the bass Drop the bass Boom Boom Boom +Boom Boom Drop the bass Drop the bass Drop the bass !!!Break the bass!!! Boom Boom Boom Boom Boom Boom -Drop the base Boom Drop the base -Drop the base Drop the base Drop the base !!!Break the base!!! +Drop the bass Boom Drop the bass +Drop the bass Drop the bass Drop the bass !!!Break the bass!!! ``` -## 馃挕 Hint: +## 馃挕 Hints: -+ Remember to use helper variables ++ Remember to use helper variables. -+ Remember your function `lyricsGenerator` should be returning a `string` ++ Remember, your function `lyricsGenerator` should be returning a `string`. From 25d561ae6579df9e4c404ecd4bdbcb340a05eb64 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:48:21 +0200 Subject: [PATCH 87/94] Update README.es.md --- exercises/25-Techno-beat/README.es.md | 37 +++++++++++---------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/exercises/25-Techno-beat/README.es.md b/exercises/25-Techno-beat/README.es.md index ae126205..81263180 100644 --- a/exercises/25-Techno-beat/README.es.md +++ b/exercises/25-Techno-beat/README.es.md @@ -1,10 +1,10 @@ -# `25` Ritmo Tecno +# `25` Techno Beats -Est谩s trabajando con un DJ y 茅l necesita un programa que pueda crear ritmos para sus canciones. +Est谩s trabajando con un DJ, y necesita un programa que pueda crear ritmos para sus canciones. ## 馃摑 Instrucciones: -1. Crear una funci贸n `lyricsGenerator` que recibe un arreglo. El arreglo enviado a la funci贸n ser谩 algo como as铆: +1. Crear una funci贸n `lyricsGenerator` que recibe un arreglo. El arreglo enviado a la funci贸n ser谩 algo as铆: ```js [0,0,1,1,0,0,0] @@ -12,29 +12,22 @@ Est谩s trabajando con un DJ y 茅l necesita un programa que pueda crear ritmos pa 2. Por cada `0`, agr茅gale al string `'Boom'`. -3. Por cada `1`, agr茅gale al string `'Drop the base'`. +3. Por cada `1`, agr茅gale al string `'Drop the bass'`. -##聽Restricciones: +4. Si encuentras el n煤mero `1` tres veces seguidas, TAMBI脡N debes AGREGAR al string `隆隆隆Break the bass!!!`. -+ Si encuentras el n煤mero Uno (1) tres veces seguidas, TAMBI脡N debes AGREGAR al string `隆隆隆Break the base!!!` - -## Resultado esperado de la funci贸n: - -Un string que debe estar compuesto por Boom o Drop the base o `!!!Break the base!!!` - -## 馃挕 Pista: - -+ Recuerda usar variables auxiliares - -+ Recuerda que tu funci贸n `lyricsGenerator` debe retornar un `string` - -## Resultado esperado: +## 馃捇 Resultado esperado: ```js -Boom Boom Drop the base Drop the base Boom Boom Boom -Boom Boom Drop the base Drop the base Drop the base !!!Break the base!!! Boom Boom Boom +Boom Boom Drop the bass Drop the bass Boom Boom Boom +Boom Boom Drop the bass Drop the bass Drop the bass !!!Break the bass!!! Boom Boom Boom Boom Boom Boom -Drop the base Boom Drop the base -Drop the base Drop the base Drop the base !!!Break the base!!! +Drop the bass Boom Drop the bass +Drop the bass Drop the bass Drop the bass !!!Break the bass!!! ``` +## 馃挕 Pistas: + ++ Recuerda usar variables auxiliares. + ++ Recuerda que tu funci贸n `lyricsGenerator` debe retornar un `string`. From e17d2f566cb6ebf252e62e123acb9ffb1c04c372 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:50:09 +0200 Subject: [PATCH 88/94] Update test.js --- exercises/25-Techno-beat/test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/25-Techno-beat/test.js b/exercises/25-Techno-beat/test.js index 1839ae3e..480c0572 100644 --- a/exercises/25-Techno-beat/test.js +++ b/exercises/25-Techno-beat/test.js @@ -20,7 +20,7 @@ test('console.log() function should have been called 5 times', function () { expect(console.log.mock.calls.length).toBe(5); }); -test('The functions returns the correct value when passing different parameters', function () { +test('The function returns the correct value when passing different parameters', function () { const app = rewire('./app.js'); const lyricsGenerator = app.__get__('lyricsGenerator'); @@ -31,15 +31,15 @@ test('The functions returns the correct value when passing different parameters' let _test5 = lyricsGenerator([1,1,1]).trim() let _test6 = lyricsGenerator([1,1,1,0,1,0,1]).trim() - expect(_test1).toBe("Boom Boom Drop the base Drop the base Boom Boom Boom"); - expect(_test2).toBe("Boom Boom Drop the base Drop the base Drop the base !!!Break the base!!! Boom Boom Boom"); + expect(_test1).toBe("Boom Boom Drop the bass Drop the bass Boom Boom Boom"); + expect(_test2).toBe("Boom Boom Drop the bass Drop the bass Drop the bass !!!Break the bass!!! Boom Boom Boom"); expect(_test3).toBe("Boom Boom Boom"); - expect(_test4).toBe("Drop the base Boom Drop the base"); - expect(_test5).toBe("Drop the base Drop the base Drop the base !!!Break the base!!!"); - expect(_test6).toBe("Drop the base Drop the base Drop the base !!!Break the base!!! Boom Drop the base Boom Drop the base"); + expect(_test4).toBe("Drop the bass Boom Drop the bass"); + expect(_test5).toBe("Drop the bass Drop the bass Drop the bass !!!Break the bass!!!"); + expect(_test6).toBe("Drop the bass Drop the bass Drop the bass !!!Break the bass!!! Boom Drop the bass Boom Drop the bass"); }); -test('The functions should be returning a string', function () { +test('The function should be returning a string', function () { const app = rewire('./app.js'); const lyricsGenerator = app.__get__('lyricsGenerator'); @@ -56,4 +56,4 @@ test('The functions should be returning a string', function () { expect(typeof(_test4)).toBe("string"); expect(typeof(_test5)).toBe("string"); expect(typeof(_test6)).toBe("string"); -}); \ No newline at end of file +}); From ae89d98dd4dbf30cbc62597a438cce6a63afeb9b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:53:09 +0200 Subject: [PATCH 89/94] Update solution.hide.js --- exercises/25-Techno-beat/solution.hide.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/25-Techno-beat/solution.hide.js b/exercises/25-Techno-beat/solution.hide.js index 8e6bbbde..ef4b7d9c 100644 --- a/exercises/25-Techno-beat/solution.hide.js +++ b/exercises/25-Techno-beat/solution.hide.js @@ -1,5 +1,5 @@ // Add your code here -function lyricsGenerator(arr){ +function lyricsGenerator(arr) { let finalString = "" let countOne = 0 @@ -7,12 +7,12 @@ function lyricsGenerator(arr){ if(arr[i] == 0){ finalString += "Boom " countOne = 0 - }else if(arr[i] == 1){ - finalString += "Drop the base " + } else if(arr[i] == 1) { + finalString += "Drop the bass " countOne += 1 - if(countOne === 3){ - finalString += "!!!Break the base!!! " + if(countOne === 3) { + finalString += "!!!Break the bass!!! " } } } @@ -25,4 +25,4 @@ console.log(lyricsGenerator([0,0,1,1,0,0,0])) console.log(lyricsGenerator([0,0,1,1,1,0,0,0])) console.log(lyricsGenerator([0,0,0])) console.log(lyricsGenerator([1,0,1])) -console.log(lyricsGenerator([1,1,1])) \ No newline at end of file +console.log(lyricsGenerator([1,1,1])) From dbeb6401a9ea0af51e15628cfc0b4aa29676b18b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:54:31 +0200 Subject: [PATCH 90/94] Update README.md --- exercises/25-Techno-beat/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/25-Techno-beat/README.md b/exercises/25-Techno-beat/README.md index 22c248b1..0ff7d03b 100644 --- a/exercises/25-Techno-beat/README.md +++ b/exercises/25-Techno-beat/README.md @@ -18,7 +18,7 @@ You are working with a DJ, and he needs a program that can create beats for his ## 馃捇 Expected Output: -```js +```text Boom Boom Drop the bass Drop the bass Boom Boom Boom Boom Boom Drop the bass Drop the bass Drop the bass !!!Break the bass!!! Boom Boom Boom Boom Boom Boom From 8090973c94a8daa5616acd13ea6141df898db1be Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:54:42 +0200 Subject: [PATCH 91/94] Update README.es.md --- exercises/25-Techno-beat/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/25-Techno-beat/README.es.md b/exercises/25-Techno-beat/README.es.md index 81263180..4b77a148 100644 --- a/exercises/25-Techno-beat/README.es.md +++ b/exercises/25-Techno-beat/README.es.md @@ -18,7 +18,7 @@ Est谩s trabajando con un DJ, y necesita un programa que pueda crear ritmos para ## 馃捇 Resultado esperado: -```js +```text Boom Boom Drop the bass Drop the bass Boom Boom Boom Boom Boom Drop the bass Drop the bass Drop the bass !!!Break the bass!!! Boom Boom Boom Boom Boom Boom From 5427cee4325282795f38d40f711a0b54e5c16905 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:58:27 +0200 Subject: [PATCH 92/94] Update app.js --- exercises/25-Techno-beat/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/25-Techno-beat/app.js b/exercises/25-Techno-beat/app.js index 3e7df5f0..ee38a649 100644 --- a/exercises/25-Techno-beat/app.js +++ b/exercises/25-Techno-beat/app.js @@ -1,4 +1,4 @@ -// Add your code here +// Your code here // Don't change anything bellow this line @@ -6,4 +6,4 @@ console.log(lyricsGenerator([0,0,1,1,0,0,0])) console.log(lyricsGenerator([0,0,1,1,1,0,0,0])) console.log(lyricsGenerator([0,0,0])) console.log(lyricsGenerator([1,0,1])) -console.log(lyricsGenerator([1,1,1])) \ No newline at end of file +console.log(lyricsGenerator([1,1,1])) From 5f329874f0676504ee5b789f475e82e7ab85cfb8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:58:34 +0200 Subject: [PATCH 93/94] Update solution.hide.js --- exercises/25-Techno-beat/solution.hide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/25-Techno-beat/solution.hide.js b/exercises/25-Techno-beat/solution.hide.js index ef4b7d9c..0a3f48bc 100644 --- a/exercises/25-Techno-beat/solution.hide.js +++ b/exercises/25-Techno-beat/solution.hide.js @@ -1,4 +1,4 @@ -// Add your code here +// Your code here function lyricsGenerator(arr) { let finalString = "" let countOne = 0 From 6ff738166586eab08435babce9482ecbbffa6695 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:59:02 +0200 Subject: [PATCH 94/94] Update app.js --- exercises/25-Techno-beat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/25-Techno-beat/app.js b/exercises/25-Techno-beat/app.js index ee38a649..d2d5848b 100644 --- a/exercises/25-Techno-beat/app.js +++ b/exercises/25-Techno-beat/app.js @@ -1,7 +1,7 @@ // Your code here -// Don't change anything bellow this line +// Don't change anything below this line console.log(lyricsGenerator([0,0,1,1,0,0,0])) console.log(lyricsGenerator([0,0,1,1,1,0,0,0])) console.log(lyricsGenerator([0,0,0]))