From 7c106b6daf0c4440f1cb17bf197300f8ed5dd1fa Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:30:22 +0200 Subject: [PATCH 01/94] Update README.md --- exercises/07.2-Letter-Counter/README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/exercises/07.2-Letter-Counter/README.md b/exercises/07.2-Letter-Counter/README.md index 0dad6dc9..2bd769ca 100644 --- a/exercises/07.2-Letter-Counter/README.md +++ b/exercises/07.2-Letter-Counter/README.md @@ -1,14 +1,12 @@ --- - tutorial: https://www.youtube.com/watch?v=oLTidCuisew - --- # `07.2` Letter Counter -Our customer needs a program that counts the number of occurences of each letter in a given string. I know that's weird, but they are very adamant. We need this asap! +Our customer needs a program that counts the number of occurrences of each letter in a given string. I know that's weird, but they are very adamant. We need this asap! -## :pencil: Instructions: +## 📝 Instructions: 1. Create an object where the letters are the properties and the values are the number of times that letter is repeated throughout the string. @@ -20,16 +18,16 @@ const word = "Hello World"; // The console should print { h: 1, e: 1, l: 3, o: 2, w: 1, r: 1, d: 1 } ``` -## :bulb: Hint +## 💡 Hints: + Loop the entire string. -+ On every iteration check if the object `counts` has the letter initialized as a property. ++ On every iteration, check if the object `counts` has the letter initialized as a property. + If the letter has not been initialized, then do it and set its value equal to 1 (first time found). -+ If it was already initialized just increment the property value by one. ++ If it was already initialized, just increment the property value by one. + Remember to ignore white spaces in the string. -+ You should lower case all letters to have an accurate count of all letters regardless of casing of the letter. ++ To accurately count all letters, regardless of their casing, you should convert all letters to lowercase. From a9d3fe2ae24f6c9fe9ef502f8b16ee33b25747c5 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:33:34 +0200 Subject: [PATCH 02/94] Update README.es.md --- exercises/07.2-Letter-Counter/README.es.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/07.2-Letter-Counter/README.es.md b/exercises/07.2-Letter-Counter/README.es.md index a17472f5..538c73f2 100644 --- a/exercises/07.2-Letter-Counter/README.es.md +++ b/exercises/07.2-Letter-Counter/README.es.md @@ -1,8 +1,8 @@ -# `07.2` Contador de letras +# `07.2` Letter Counter Nuestro cliente necesita un programa que cuente las repeticiones de las letras en un string dado. Sé que es extraño, pero es muy testarudo ¡Lo necesitamos lo antes posible! -## :pencil: Instrucciones: +## 📝 Instrucciones: 1. Crea un objeto donde las letras son las propiedades y los valores son el número de veces que esa letra se repite en toda la cadena. @@ -14,7 +14,7 @@ const word = "Hello World"; // Debería imprimir en la consola { h: 1, e: 1, l: 3, o: 2, w: 1, r: 1, d: 1 } ``` -## :bulb: Pista: +## 💡 Pistas: + Recorre todo el string (usa un bucle). From 5536dd642f442380759c2847e0620654876b21f0 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:34:06 +0200 Subject: [PATCH 03/94] Update app.js --- exercises/07.2-Letter-Counter/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/07.2-Letter-Counter/app.js b/exercises/07.2-Letter-Counter/app.js index ea913651..c2557ef2 100644 --- a/exercises/07.2-Letter-Counter/app.js +++ b/exercises/07.2-Letter-Counter/app.js @@ -1,6 +1,6 @@ let par = "Lorem ipsum dolor sit amet consectetur adipiscing elit Curabitur eget bibendum turpis Curabitur scelerisque eros ultricies venenatis mi at tempor nisl Integer tincidunt accumsan cursus" let counts = {}; -// your code here +// Your code here -console.log(counts); \ No newline at end of file +console.log(counts); From 1fc9b30ec86eb303aba20b6e3be46017b14e1d01 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:38:50 +0200 Subject: [PATCH 04/94] Update solution.hide.js --- exercises/07.2-Letter-Counter/solution.hide.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/exercises/07.2-Letter-Counter/solution.hide.js b/exercises/07.2-Letter-Counter/solution.hide.js index 2662a35b..5a5b65f2 100644 --- a/exercises/07.2-Letter-Counter/solution.hide.js +++ b/exercises/07.2-Letter-Counter/solution.hide.js @@ -1,20 +1,16 @@ let par = "Lorem ipsum dolor sit amet consectetur adipiscing elit Curabitur eget bibendum turpis Curabitur scelerisque eros ultricies venenatis mi at tempor nisl Integer tincidunt accumsan cursus" let counts = {}; -// your code here -for(let i in par){ +// Your code here +for(let i in par) { const letter = par[i].toLowerCase(); - console.log(letter); if(letter == " ") continue; - else if(counts[letter] == undefined){ - console.log("Found "+letter+" for the first time") + else if(counts[letter] == undefined) { counts[letter] = 1; } - else{ - console.log("Found "+letter+" more than once") + else { counts[letter] = counts[letter] + 1; - } } -console.log(counts); \ No newline at end of file +console.log(counts); From f2301bf58cc6c136f7104ad1b9cd7de957f32a67 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:39:36 +0200 Subject: [PATCH 05/94] Update tests.js --- exercises/07.2-Letter-Counter/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/07.2-Letter-Counter/tests.js b/exercises/07.2-Letter-Counter/tests.js index 902caad6..8ca80817 100644 --- a/exercises/07.2-Letter-Counter/tests.js +++ b/exercises/07.2-Letter-Counter/tests.js @@ -13,7 +13,7 @@ it('You have to use the console.log function once, at the end of the exercise', expect(console.log.mock.calls.length).toBe(1); }); -it('Use a for loop', function () { +it('Use a "for" loop', function () { const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); expect(app_content).toMatch(/for(\s*)\(/); }); @@ -37,4 +37,4 @@ it('Create the object with the letter counts like { a: 1, b: 4, ... }', function } expect(counts).toEqual(_counts); -}); \ No newline at end of file +}); From d3401d847eb8b295de65e11e4ff25779241d344e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:10:18 +0200 Subject: [PATCH 06/94] Update README.md --- exercises/07.3-Flip-Array/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/07.3-Flip-Array/README.md b/exercises/07.3-Flip-Array/README.md index 471a9b01..cd190f3d 100644 --- a/exercises/07.3-Flip-Array/README.md +++ b/exercises/07.3-Flip-Array/README.md @@ -4,7 +4,7 @@ tutorial: https://www.youtube.com/watch?v=Snn7OtZY370 # `07.3` Flip Array -## :pencil: Instructions: +## 📝 Instructions: 1. Using a `for` loop, invert the `arr` array and print the new array on the console. @@ -15,8 +15,8 @@ Initial array: [45, 67, 87, 23, 5, 32, 60]; Final array: [60, 32, 5 , 23, 87, 67, 45]; ``` -## :bulb: Hint +## 💡 Hints: -+ You should loop the entire array [from the end to the beggining](https://stackoverflow.com/questions/1340589/are-loops-really-faster-in-reverse). ++ You should loop the entire array [from the end to the beginning](https://stackoverflow.com/questions/1340589/are-loops-really-faster-in-reverse). -+ On each loop push all the items (as you go) into a new array, this will be your flipped array. What other methods can you use besides `push()`? ++ On each loop, push all the items (as you go) into a new array, this will be your flipped array. What other methods can you use besides `push()`? From 32160285063aa5354bc15b111fb2576b853f510f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:13:57 +0200 Subject: [PATCH 07/94] Update README.es.md --- exercises/07.3-Flip-Array/README.es.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/07.3-Flip-Array/README.es.md b/exercises/07.3-Flip-Array/README.es.md index 900a0a16..e92ab0c1 100644 --- a/exercises/07.3-Flip-Array/README.es.md +++ b/exercises/07.3-Flip-Array/README.es.md @@ -1,18 +1,18 @@ -# `07.3` Invierte el Array +# `07.3` Flip Array -## :pencil: Instrucciones: +## 📝 Instrucciones: -1. Usando un bucle `for`, invierte el arreglo o array `arr` e imprime el nuevo arreglo o array en la consola. +1. Usando un bucle `for`, invierte el array `arr` e imprime el nuevo array en la consola. Por ejemplo: ```js - array inicial: [45, 67, 87, 23, 5, 32, 60]; array array final : [60, 32, 5 , 23, 87, 67, 45]; +Initial array: [45, 67, 87, 23, 5, 32, 60]; +Final array: [60, 32, 5 , 23, 87, 67, 45]; ``` -## :bulb: Pista +## 💡 Pistas: + Debes recorrer todo el arreglo [desde el final hasta el principio](https://stackoverflow.com/questions/1340589/are-loops-really-faster-in-reverse). -+ En cada bucle, inserta todos los elementos (a -medida que avanza) en un nuevo array o arreglo, este será tu arreglo invertido. \ No newline at end of file ++ En cada bucle, inserta todos los elementos (a medida que avanza) en un nuevo array, este será tu arreglo invertido. Qué otros métodos puedes usar además de `push()`? From 04f79241384fcb5f40e67f61d3904c723a8fc557 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:14:19 +0200 Subject: [PATCH 08/94] Update README.es.md --- exercises/07.3-Flip-Array/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/07.3-Flip-Array/README.es.md b/exercises/07.3-Flip-Array/README.es.md index e92ab0c1..7b04bb90 100644 --- a/exercises/07.3-Flip-Array/README.es.md +++ b/exercises/07.3-Flip-Array/README.es.md @@ -15,4 +15,4 @@ Final array: [60, 32, 5 , 23, 87, 67, 45]; + Debes recorrer todo el arreglo [desde el final hasta el principio](https://stackoverflow.com/questions/1340589/are-loops-really-faster-in-reverse). -+ En cada bucle, inserta todos los elementos (a medida que avanza) en un nuevo array, este será tu arreglo invertido. Qué otros métodos puedes usar además de `push()`? ++ En cada bucle, inserta todos los elementos (a medida que avanza) en un nuevo array, este será tu arreglo invertido. ¿Qué otros métodos puedes usar además de `push()`? From 9530732671dd1945e99aaea319447f2e4d71c4ef Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:15:15 +0200 Subject: [PATCH 09/94] Update README.es.md --- exercises/07.3-Flip-Array/README.es.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/07.3-Flip-Array/README.es.md b/exercises/07.3-Flip-Array/README.es.md index 7b04bb90..f957c49c 100644 --- a/exercises/07.3-Flip-Array/README.es.md +++ b/exercises/07.3-Flip-Array/README.es.md @@ -7,8 +7,8 @@ Por ejemplo: ```js -Initial array: [45, 67, 87, 23, 5, 32, 60]; -Final array: [60, 32, 5 , 23, 87, 67, 45]; +Initial array: [45, 67, 87, 23, 5, 32, 60]; +Final array: [60, 32, 5, 23, 87, 67, 45]; ``` ## 💡 Pistas: From f1df862673b2fdd22da82fc40bc15a651d8125a8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:15:30 +0200 Subject: [PATCH 10/94] Update README.md --- exercises/07.3-Flip-Array/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/07.3-Flip-Array/README.md b/exercises/07.3-Flip-Array/README.md index cd190f3d..fadb0080 100644 --- a/exercises/07.3-Flip-Array/README.md +++ b/exercises/07.3-Flip-Array/README.md @@ -11,8 +11,8 @@ tutorial: https://www.youtube.com/watch?v=Snn7OtZY370 For example: ```js -Initial array: [45, 67, 87, 23, 5, 32, 60]; -Final array: [60, 32, 5 , 23, 87, 67, 45]; +Initial array: [45, 67, 87, 23, 5, 32, 60]; +Final array: [60, 32, 5, 23, 87, 67, 45]; ``` ## 💡 Hints: From 7a638ea5033818336c2d8c33c5e06d9c5659601c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:15:55 +0200 Subject: [PATCH 11/94] Update app.js --- exercises/07.3-Flip-Array/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/07.3-Flip-Array/app.js b/exercises/07.3-Flip-Array/app.js index 4876d9ad..6d1a63d4 100644 --- a/exercises/07.3-Flip-Array/app.js +++ b/exercises/07.3-Flip-Array/app.js @@ -1,3 +1,3 @@ let arr = [45,67,87,23,5,32,60]; -//Your code here. +// Your code here From 64cb4225c87757906e922a8ae3c31c479e2aaa33 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:16:44 +0200 Subject: [PATCH 12/94] Update solution.hide.js --- exercises/07.3-Flip-Array/solution.hide.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/exercises/07.3-Flip-Array/solution.hide.js b/exercises/07.3-Flip-Array/solution.hide.js index 71a2b3b5..3ed2a36e 100644 --- a/exercises/07.3-Flip-Array/solution.hide.js +++ b/exercises/07.3-Flip-Array/solution.hide.js @@ -1,9 +1,10 @@ let arr = [45,67,87,23,5,32,60]; -//Your code here. +// Your code here let flippedArray = [] -for(let i = arr.length - 1; i>= 0;i--){ +for(let i = arr.length - 1; i >= 0; i--) { let item = arr[i]; flippedArray.push(item); } -console.log(flippedArray) \ No newline at end of file + +console.log(flippedArray) From 3cc40e6bcbdaebea2e4f2148c3db37d33bac91a2 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:50:17 +0200 Subject: [PATCH 13/94] removed not needed test (typeof) --- exercises/07.3-Flip-Array/tests.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/exercises/07.3-Flip-Array/tests.js b/exercises/07.3-Flip-Array/tests.js index 3eb7484b..c12efb2f 100644 --- a/exercises/07.3-Flip-Array/tests.js +++ b/exercises/07.3-Flip-Array/tests.js @@ -9,23 +9,18 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); let reverse = Array.prototype.reverse; Array.prototype.reverse = jest.fn(function(){ return this; }); -it('Use the console.log function once to print the new array with the types on the console', function () { +it('Use the console.log function once', function () { const app = require('./app.js'); expect(console.log.mock.calls.length).toBe(1); }); -it("Use the typeof function inside the loop", function () { - const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); - expect(app_content).not.toMatch(/\.typeof/); -}); - -it('There needs to be a variable called arr with the original array', function () { +it('There needs to be a variable called "arr" with the original array', function () { const _app = rewire('./app.js'); const variable = _app.__get__('arr'); expect(variable).toBeTruthy(); }); -it('Loop the array in a reverse order and console.log all of its item', function () { +it('Loop the array in a reverse order and console.log all of its items', function () { const _app = rewire('./app.js'); const variable = _app.__get__('arr'); let inverted = []; @@ -33,4 +28,4 @@ it('Loop the array in a reverse order and console.log all of its item', function inverted.push(variable[i]); } expect(_buffer).toMatch(inverted.map(n => n).join(",")); -}); \ No newline at end of file +}); From cebe26ac60444b8d7998e6a4838fd1a4394753f5 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:53:57 +0200 Subject: [PATCH 14/94] Update tests.js --- exercises/07.3-Flip-Array/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/07.3-Flip-Array/tests.js b/exercises/07.3-Flip-Array/tests.js index c12efb2f..706e506a 100644 --- a/exercises/07.3-Flip-Array/tests.js +++ b/exercises/07.3-Flip-Array/tests.js @@ -9,7 +9,7 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); let reverse = Array.prototype.reverse; Array.prototype.reverse = jest.fn(function(){ return this; }); -it('Use the console.log function once', function () { +it('Use the console.log function once, at the end of the exercise', function () { const app = require('./app.js'); expect(console.log.mock.calls.length).toBe(1); }); From 3bc6debc7d9fa67c850d2dc665f91bded3c00194 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:57:52 +0200 Subject: [PATCH 15/94] Update README.md --- exercises/08.1-Mixed-array/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/08.1-Mixed-array/README.md b/exercises/08.1-Mixed-array/README.md index 40d77253..61ad5d96 100644 --- a/exercises/08.1-Mixed-array/README.md +++ b/exercises/08.1-Mixed-array/README.md @@ -2,13 +2,13 @@ tutorial: https://www.youtube.com/watch?v=3o02odJhieo --- -# `08.01` Mixed Array +# `08.1` Mixed Array -## :pencil: Instructions: +## 📝 Instructions: 1. Write a function that prints in the console a new array that contains all the types of data that the array `mix` contains in each position. -### Expected Result: +## 💻 Expected Result: ```js [ @@ -19,14 +19,14 @@ tutorial: https://www.youtube.com/watch?v=3o02odJhieo ] ``` -## :bulb: Hints: +## 💡 Hints: + Create a new empty array. + Loop the original array. -+ On every loop get the type of the item using the `typeof` function. ++ On every loop, get the type of the item using the `typeof` function. -+ Since the `typeof` function return a string you can push that string to the new array. ++ Since the `typeof` function returns a string you can push that string to the new array. -+ when the loop finished, you should have all the types found on the original array pushed to the new array. \ No newline at end of file ++ When the loop is finished, you should have all the types found on the original array pushed to the new array. From cfffb8e45375cfc892156c46a2200610909f3e11 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:00:35 +0200 Subject: [PATCH 16/94] Update README.es.md --- exercises/08.1-Mixed-array/README.es.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/08.1-Mixed-array/README.es.md b/exercises/08.1-Mixed-array/README.es.md index d5bf7c79..4cf01d3d 100644 --- a/exercises/08.1-Mixed-array/README.es.md +++ b/exercises/08.1-Mixed-array/README.es.md @@ -1,10 +1,10 @@ -# `08.01` Array mixto +# `08.1` Mixed Array -## :pencil: Instrucciones: +## 📝 Instrucciones: 1. Escribe una función que imprima un arreglo en la consola que contenga los tipos de valores (data-types) que contiene el array `mix` en cada posición. -### Resultado esperado: +## 💻 Resultado esperado: ```js [ @@ -15,7 +15,7 @@ ] ``` -## :bulb: Pista +## 💡 Pista + Crea un nuevo arreglo vacío. @@ -23,6 +23,6 @@ + En cada bucle, obten el tipo de elemento utilizando la función `typeof`. -+ Como la función `typeof` devuelve un string, puedes insertar(push) ese string en el nuevo arreglo(array). ++ Como la función `typeof` devuelve un string, puedes insertar(push) ese string en el nuevo arreglo. -+ Cuando finalice el bucle o loop, debes haber encontrado todos los tipos de elementos del arreglo o array original y haberlos insertados(push) en el nuevo arreglo. \ No newline at end of file ++ Cuando finalice el bucle, debes haber encontrado todos los tipos de elementos del arreglo original y haberlos insertados(push) en el nuevo arreglo. From 5454569ba6eae6f637a54d453ae10f81714ffd3b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:01:15 +0200 Subject: [PATCH 17/94] Update README.es.md --- exercises/08.1-Mixed-array/README.es.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/08.1-Mixed-array/README.es.md b/exercises/08.1-Mixed-array/README.es.md index 4cf01d3d..2fd69f33 100644 --- a/exercises/08.1-Mixed-array/README.es.md +++ b/exercises/08.1-Mixed-array/README.es.md @@ -21,8 +21,8 @@ + Recorre el arreglo original mediante un bucle. -+ En cada bucle, obten el tipo de elemento utilizando la función `typeof`. ++ En cada bucle, obtén el tipo de elemento utilizando la función `typeof`. + Como la función `typeof` devuelve un string, puedes insertar(push) ese string en el nuevo arreglo. -+ Cuando finalice el bucle, debes haber encontrado todos los tipos de elementos del arreglo original y haberlos insertados(push) en el nuevo arreglo. ++ Cuando finalice el bucle, debes haber encontrado todos los tipos de elementos del arreglo original y haberlos insertado(push) en el nuevo arreglo. From e67d519d664bb07a56a9be32ae43348747317ca6 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:05:55 +0200 Subject: [PATCH 18/94] Update app.js --- exercises/08.1-Mixed-array/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.1-Mixed-array/app.js b/exercises/08.1-Mixed-array/app.js index fc215a43..15dcd2e8 100644 --- a/exercises/08.1-Mixed-array/app.js +++ b/exercises/08.1-Mixed-array/app.js @@ -1,3 +1,3 @@ let mix = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; -//your code here \ No newline at end of file +// Your code here From e30fb10c4a0e85d84f688733f97016ea90af8aa1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:06:29 +0200 Subject: [PATCH 19/94] Update solution.hide.js --- exercises/08.1-Mixed-array/solution.hide.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/08.1-Mixed-array/solution.hide.js b/exercises/08.1-Mixed-array/solution.hide.js index 87b987f3..fca7698b 100644 --- a/exercises/08.1-Mixed-array/solution.hide.js +++ b/exercises/08.1-Mixed-array/solution.hide.js @@ -1,10 +1,10 @@ let mix = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; -//your code here +// Your code here let newArray = []; for (let i = 0; i < mix.length; i++) { const item = mix[i]; newArray.push(typeof item) - } -console.log(newArray) \ No newline at end of file + +console.log(newArray) From 3273bcc712e41c9ebb70c885689e88edb454162e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:08:02 +0200 Subject: [PATCH 20/94] removed test not needed for this exercise --- exercises/08.1-Mixed-array/tests.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/exercises/08.1-Mixed-array/tests.js b/exercises/08.1-Mixed-array/tests.js index f29a2263..992a0290 100644 --- a/exercises/08.1-Mixed-array/tests.js +++ b/exercises/08.1-Mixed-array/tests.js @@ -14,11 +14,6 @@ it("Create a loop", function () { expect(app_content).toMatch(/for\s*/); }); -it("Don't use the reverse function", function () { - const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); - expect(app_content).not.toMatch(/\.reverse(\s*)\(/); -}); - it('Use the console.log function once to print the newArray on the console', function () { const app = require('./app.js'); expect(console.log.mock.calls.length).toBe(1); @@ -45,4 +40,4 @@ it('Loop the array and console.log all of its item types', function () { let _test = myFunc() expect(_buffer).toMatch(_test.map(n => n).join(",")); // expect(_buffer).toMatch(inverted.map(n => n).join(",")); -}); \ No newline at end of file +}); From 45c8d546918a3f506eba183337525c3d43d5df0b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:20:59 +0200 Subject: [PATCH 21/94] Update tests.js --- exercises/08.1-Mixed-array/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.1-Mixed-array/tests.js b/exercises/08.1-Mixed-array/tests.js index 992a0290..83bcf353 100644 --- a/exercises/08.1-Mixed-array/tests.js +++ b/exercises/08.1-Mixed-array/tests.js @@ -19,7 +19,7 @@ it('Use the console.log function once to print the newArray on the console', fun expect(console.log.mock.calls.length).toBe(1); }); -it('There needs to be a variable called mix with the original array', function () { +it('There needs to be a variable called "mix" with the original array', function () { const _app = rewire('./app.js'); const variable = _app.__get__('mix'); expect(variable).toBeTruthy(); From e0848717fa576df62c5424a1cf7765a3da7f63ee Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:26:23 +0200 Subject: [PATCH 22/94] Update README.md --- exercises/08.2-Count-On/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/08.2-Count-On/README.md b/exercises/08.2-Count-On/README.md index c86c66f8..476e8f55 100644 --- a/exercises/08.2-Count-On/README.md +++ b/exercises/08.2-Count-On/README.md @@ -1,23 +1,23 @@ # `08.2` Count On -As you saw in the last exercise your array can be a mix of data types. +As you saw in the last exercise, your array can be a mix of data types. -## :pencil: Instructions: +## 📝 Instructions: 1. Add all the items with data type 'object' into the `hello` array. -Here is how to print all the items. +Here is how to print all the items: ```js let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; -for(let index = 0; index < myArray.length; index++){ +for(let index = 0; index < myArray.length; index++) { let item = myArray[index]; console.log(typeof(item)) } ``` -## :bulb: Hint: +## 💡 Hints: + Loop the given array. From 498c03df31637cddb052b981b692772d29497259 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:28:28 +0200 Subject: [PATCH 23/94] Update README.es.md --- exercises/08.2-Count-On/README.es.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/08.2-Count-On/README.es.md b/exercises/08.2-Count-On/README.es.md index c7a3f05f..cbfc0a5c 100644 --- a/exercises/08.2-Count-On/README.es.md +++ b/exercises/08.2-Count-On/README.es.md @@ -2,27 +2,27 @@ Como viste en el último ejercicio, tu arreglo o array puede tener una mezcla de tipos de datos. -## :pencil: Instrucciones +## 📝 Instrucciones: 1. Agrega todos los elementos con tipo de dato objeto dentro del array `hello`. -Aquí puedes ver cómo imprimir TODOS los elementos. +Aquí puedes ver cómo imprimir todos los elementos: ```js let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; -for(let index = 0; index < myArray.length; index++){ +for(let index = 0; index < myArray.length; index++) { let item = myArray[index]; console.log(typeof(item)) } ``` -## :bulb: Pista +## 💡 Pistas: + Recorre el array dado con un loop. -+ Agrega una condición dentro del bucle(loop) que verifique que el elemento sea un objeto. ++ Agrega una condición dentro del bucle que verifique que el elemento sea un objeto. + Si el elemento es un objeto, se agrega al arreglo `hello`. -+ Usa `console.log()`para imprimir el array `hello` en la consola. ++ Usa `console.log()` para imprimir el array `hello` en la consola. From bdc4889afb5c41b91ac06398c59f789bb3d7f3e7 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:32:00 +0200 Subject: [PATCH 24/94] Update README.md --- exercises/08.2-Count-On/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/08.2-Count-On/README.md b/exercises/08.2-Count-On/README.md index 476e8f55..97e89617 100644 --- a/exercises/08.2-Count-On/README.md +++ b/exercises/08.2-Count-On/README.md @@ -6,12 +6,12 @@ As you saw in the last exercise, your array can be a mix of data types. 1. Add all the items with data type 'object' into the `hello` array. -Here is how to print all the items: +Here is how to print all the item types: ```js let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; -for(let index = 0; index < myArray.length; index++) { +for(let i = 0; i < myArray.length; i++) { let item = myArray[index]; console.log(typeof(item)) } From 10eb603e5e17dc445dfaadd2e0d9e4a50aac4d1a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:32:42 +0200 Subject: [PATCH 25/94] Update README.es.md --- exercises/08.2-Count-On/README.es.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/08.2-Count-On/README.es.md b/exercises/08.2-Count-On/README.es.md index cbfc0a5c..cec473f4 100644 --- a/exercises/08.2-Count-On/README.es.md +++ b/exercises/08.2-Count-On/README.es.md @@ -6,13 +6,13 @@ Como viste en el último ejercicio, tu arreglo o array puede tener una mezcla de 1. Agrega todos los elementos con tipo de dato objeto dentro del array `hello`. -Aquí puedes ver cómo imprimir todos los elementos: +Aquí puedes ver cómo imprimir los tipos de elementos: ```js let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; -for(let index = 0; index < myArray.length; index++) { - let item = myArray[index]; +for(let i = 0; i < myArray.length; i++) { + let item = myArray[i]; console.log(typeof(item)) } ``` From e9b79d3cea63b5c3ceba5642acfde6e1774eb245 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:32:52 +0200 Subject: [PATCH 26/94] Update README.md --- exercises/08.2-Count-On/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.2-Count-On/README.md b/exercises/08.2-Count-On/README.md index 97e89617..dc1f0fe9 100644 --- a/exercises/08.2-Count-On/README.md +++ b/exercises/08.2-Count-On/README.md @@ -12,7 +12,7 @@ Here is how to print all the item types: let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; for(let i = 0; i < myArray.length; i++) { - let item = myArray[index]; + let item = myArray[i]; console.log(typeof(item)) } ``` From 41f5ae1c1df32fea6427a8c7b5360aa655a77d79 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:33:31 +0200 Subject: [PATCH 27/94] Update app.js --- exercises/08.2-Count-On/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/08.2-Count-On/app.js b/exercises/08.2-Count-On/app.js index 30e7a6c5..05f8401d 100644 --- a/exercises/08.2-Count-On/app.js +++ b/exercises/08.2-Count-On/app.js @@ -1,9 +1,9 @@ let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; let hello = []; -for(let index = 0; index < myArray.length; index++){ - let element = myArray[index]; +for(let i = 0; i < myArray.length; i++){ + let element = myArray[i]; // MAGIC HAPPENS HERE } -console.log(hello) \ No newline at end of file +console.log(hello) From ea0f3aecabccc3cbf7d6c8a14174966531568dc3 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:33:40 +0200 Subject: [PATCH 28/94] Update app.js --- exercises/08.2-Count-On/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.2-Count-On/app.js b/exercises/08.2-Count-On/app.js index 05f8401d..431f116b 100644 --- a/exercises/08.2-Count-On/app.js +++ b/exercises/08.2-Count-On/app.js @@ -1,7 +1,7 @@ let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; let hello = []; -for(let i = 0; i < myArray.length; i++){ +for(let i = 0; i < myArray.length; i++) { let element = myArray[i]; // MAGIC HAPPENS HERE } From b1c0efd26fbb5115647f58d9e6d189ad12ec2e3c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:34:24 +0200 Subject: [PATCH 29/94] Update solution.hide.js --- exercises/08.2-Count-On/solution.hide.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/08.2-Count-On/solution.hide.js b/exercises/08.2-Count-On/solution.hide.js index 501331e5..8d21af58 100644 --- a/exercises/08.2-Count-On/solution.hide.js +++ b/exercises/08.2-Count-On/solution.hide.js @@ -1,7 +1,7 @@ let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; let hello = []; -for(let i = 0; i < myArray.length; i++){ +for(let i = 0; i < myArray.length; i++) { let item = myArray[i]; // MAGIC HAPPENS HERE if (typeof item === 'object') { @@ -9,4 +9,4 @@ for(let i = 0; i < myArray.length; i++){ } } -console.log(hello) \ No newline at end of file +console.log(hello) From 2b8b7059b3f5b701226b112f8fb1d927c4724c6a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:40:49 +0200 Subject: [PATCH 30/94] Update README.md --- exercises/08.2-Count-On/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/08.2-Count-On/README.md b/exercises/08.2-Count-On/README.md index dc1f0fe9..09a10165 100644 --- a/exercises/08.2-Count-On/README.md +++ b/exercises/08.2-Count-On/README.md @@ -17,6 +17,8 @@ for(let i = 0; i < myArray.length; i++) { } ``` +> Note: You may notice that when checking the type of an array, it outputs 'object'. Don't worry about that for now and proceed with the exercise normally. + ## 💡 Hints: + Loop the given array. From b286c8ab9723477afb60e341ea2cfadb16aab47a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:45:29 +0200 Subject: [PATCH 31/94] Update README.es.md --- exercises/08.2-Count-On/README.es.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exercises/08.2-Count-On/README.es.md b/exercises/08.2-Count-On/README.es.md index cec473f4..4132c573 100644 --- a/exercises/08.2-Count-On/README.es.md +++ b/exercises/08.2-Count-On/README.es.md @@ -17,6 +17,8 @@ for(let i = 0; i < myArray.length; i++) { } ``` +> Nota: Te darás cuenta que cuando verificas el tipo de dato de un array, te devolverá que es un `'object'`. Puedes investigar el por qué en Google o proceder con el ejercicio como de costumbre. + ## 💡 Pistas: + Recorre el array dado con un loop. From 657b4277aa61b2cdd2a9c333d3e88c479ff66679 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:46:49 +0200 Subject: [PATCH 32/94] Update README.md --- exercises/08.2-Count-On/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.2-Count-On/README.md b/exercises/08.2-Count-On/README.md index 09a10165..5299782c 100644 --- a/exercises/08.2-Count-On/README.md +++ b/exercises/08.2-Count-On/README.md @@ -17,7 +17,7 @@ for(let i = 0; i < myArray.length; i++) { } ``` -> Note: You may notice that when checking the type of an array, it outputs 'object'. Don't worry about that for now and proceed with the exercise normally. +> Note: You may notice that when checking the type of an array, it outputs `'object'`. You can search about it on Google or proceed with the exercise normally. ## 💡 Hints: From a2c258dd0f2983fa9b57332d5e876feb84730b86 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:47:38 +0200 Subject: [PATCH 33/94] Update app.js --- exercises/08.2-Count-On/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.2-Count-On/app.js b/exercises/08.2-Count-On/app.js index 431f116b..7d75c74a 100644 --- a/exercises/08.2-Count-On/app.js +++ b/exercises/08.2-Count-On/app.js @@ -2,7 +2,7 @@ let myArray = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; let hello = []; for(let i = 0; i < myArray.length; i++) { - let element = myArray[i]; + let item = myArray[i]; // MAGIC HAPPENS HERE } From a761874d4f195c9e9aaa90973d46c0b69a60729e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:54:16 +0200 Subject: [PATCH 34/94] Update README.md --- exercises/08.1-Mixed-array/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.1-Mixed-array/README.md b/exercises/08.1-Mixed-array/README.md index 61ad5d96..507109f1 100644 --- a/exercises/08.1-Mixed-array/README.md +++ b/exercises/08.1-Mixed-array/README.md @@ -6,7 +6,7 @@ tutorial: https://www.youtube.com/watch?v=3o02odJhieo ## 📝 Instructions: -1. Write a function that prints in the console a new array that contains all the types of data that the array `mix` contains in each position. +1. Using a loop, print in the console a new array that contains all the types of data that the array `mix` contains in each position. ## 💻 Expected Result: From 70e41a09fba68581b486a509377718b2909ffa68 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:55:32 +0200 Subject: [PATCH 35/94] Update README.es.md --- exercises/08.1-Mixed-array/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.1-Mixed-array/README.es.md b/exercises/08.1-Mixed-array/README.es.md index 2fd69f33..3c909eae 100644 --- a/exercises/08.1-Mixed-array/README.es.md +++ b/exercises/08.1-Mixed-array/README.es.md @@ -2,7 +2,7 @@ ## 📝 Instrucciones: -1. Escribe una función que imprima un arreglo en la consola que contenga los tipos de valores (data-types) que contiene el array `mix` en cada posición. +1. Usando un bucle, imprime un nuevo array en la consola que contenga los tipos de valores (data-types) que contiene el array `mix` en cada posición. ## 💻 Resultado esperado: From 3db37adbd063a0a39f2b4c226608bf263acc105b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:55:47 +0200 Subject: [PATCH 36/94] Update tests.js --- exercises/08.2-Count-On/tests.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/08.2-Count-On/tests.js b/exercises/08.2-Count-On/tests.js index a5d571a2..8d3eca0a 100644 --- a/exercises/08.2-Count-On/tests.js +++ b/exercises/08.2-Count-On/tests.js @@ -8,20 +8,20 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); -it('Use the console.log function once to print the variable hello', function () { +it('Use the console.log function once to print the variable "hello"', function () { const app = require('./app.js'); expect(console.log.mock.calls.length).toBe(1); }); -it("Use a for loop", function () { +it('Use a "for" loop', function () { expect(app_content).toMatch(/for(\s*)\(/); }); -it("Use a condition 'if' statement only for items of type object", function () { +it('Use a conditional "if" statement only for items of type \'object\'', function () { expect(app_content).toMatch(/if(\s*)\(/); }); -it("Do not cheat using the function filter", function () { +it('Do not cheat using the function filter', function () { expect(app_content).not.toMatch(/\.filter(\s*)\(/); }); @@ -32,11 +32,11 @@ it("Do not cheat using the function filter", function () { // expect(variable.filter(item => typeof(item) === "object")).toMatch(hello); // }); -it('The new array "hello" should only contain the "objects" in myArray', function () { +it("The new array \"hello\" should only contain the 'object' types in myArray", function () { const _app = rewire('./app.js'); const variable = _app.__get__('myArray'); const hello = _app.__get__('hello'); const elements = variable.filter(item => typeof(item) === 'object'); expect(hello).toEqual(elements); -}); \ No newline at end of file +}); From b4eabae854c7aedde91e0fd9ca685e337b705f1f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 19:56:29 +0200 Subject: [PATCH 37/94] Update tests.js --- exercises/08.2-Count-On/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.2-Count-On/tests.js b/exercises/08.2-Count-On/tests.js index 8d3eca0a..92a1c28c 100644 --- a/exercises/08.2-Count-On/tests.js +++ b/exercises/08.2-Count-On/tests.js @@ -32,7 +32,7 @@ it('Do not cheat using the function filter', function () { // expect(variable.filter(item => typeof(item) === "object")).toMatch(hello); // }); -it("The new array \"hello\" should only contain the 'object' types in myArray", function () { +it('The new array "hello" should only contain the \'object\' types in myArray', function () { const _app = rewire('./app.js'); const variable = _app.__get__('myArray'); const hello = _app.__get__('hello'); From 39d79a723e65addd483aff19bb5b5dce66dd77c0 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:02:43 +0200 Subject: [PATCH 38/94] Update README.md --- exercises/08.3-Sum-all-items/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/exercises/08.3-Sum-all-items/README.md b/exercises/08.3-Sum-all-items/README.md index 050a8268..a12b0c3f 100644 --- a/exercises/08.3-Sum-all-items/README.md +++ b/exercises/08.3-Sum-all-items/README.md @@ -1,14 +1,15 @@ # `08.3` Sum All Items -## :pencil: Instructions: +## 📝 Instructions: Using a `for` loop, complete the code of the function `sumTheElements` so that it returns the sum of all the items in a given array, for example: ```js console.log(sumTheElements([2,13,34,5])) -//this should print 54 +// This should print 54 ``` -## :bulb: Hint: + +## 💡 Hints: + Initialize a variable `total` at 0. @@ -20,7 +21,7 @@ console.log(sumTheElements([2,13,34,5])) + Return the `total` variable (outside of the loop but inside of the function). -### Expected result: +## 💻 Expected result: ```js 54 From 273f768f8b3b83468a29f185a1936ea1cd8b3bfb Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:06:11 +0200 Subject: [PATCH 39/94] Update app.js --- exercises/08.3-Sum-all-items/app.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/exercises/08.3-Sum-all-items/app.js b/exercises/08.3-Sum-all-items/app.js index 3e25668e..229d939f 100644 --- a/exercises/08.3-Sum-all-items/app.js +++ b/exercises/08.3-Sum-all-items/app.js @@ -1,6 +1,8 @@ -function sumTheElements(theArray){ +function sumTheElements(theArray) { let total = 0; - //your code here + // Your code here return total; -} \ No newline at end of file +} + +console.log(sumTheElements([2,13,34,5])) From 5d73d1ff221c92305bf240d04b4c2b0c8a8879a2 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:07:02 +0200 Subject: [PATCH 40/94] Update tests.js --- exercises/08.3-Sum-all-items/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/08.3-Sum-all-items/tests.js b/exercises/08.3-Sum-all-items/tests.js index 71dba1db..0deaa6ca 100644 --- a/exercises/08.3-Sum-all-items/tests.js +++ b/exercises/08.3-Sum-all-items/tests.js @@ -8,11 +8,11 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n"); const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); -it("Use a for loop", function () { +it('Use a "for" loop', function () { expect(app_content).toMatch(/for(\s*)\(/); }); -it("Do not cheat using the function .forEach", function () { +it('Do not cheat using the function .forEach', function () { expect(app_content).not.toMatch(/\.forEach(\s*)\(/); }); From 22abb101668df041e9aa11555e4359690c66e978 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:07:14 +0200 Subject: [PATCH 41/94] Update app.js --- exercises/08.3-Sum-all-items/app.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/exercises/08.3-Sum-all-items/app.js b/exercises/08.3-Sum-all-items/app.js index 229d939f..ad2ffb38 100644 --- a/exercises/08.3-Sum-all-items/app.js +++ b/exercises/08.3-Sum-all-items/app.js @@ -4,5 +4,3 @@ function sumTheElements(theArray) { return total; } - -console.log(sumTheElements([2,13,34,5])) From aabdb6b09152716690fe656b7e63ff5f50ec4b91 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:08:31 +0200 Subject: [PATCH 42/94] Update solution.hide.js --- exercises/08.3-Sum-all-items/solution.hide.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/exercises/08.3-Sum-all-items/solution.hide.js b/exercises/08.3-Sum-all-items/solution.hide.js index 95155b05..8a0a756f 100644 --- a/exercises/08.3-Sum-all-items/solution.hide.js +++ b/exercises/08.3-Sum-all-items/solution.hide.js @@ -1,13 +1,12 @@ -function sumTheElements(sumArray){ +function sumTheElements(theArray) { - sumArray =[2,13,34,5] let total = 0; - - //your code here - for (let i = 0; i < sumArray.length; i++) { - - total += sumArray[i] + // Your code here + for (let i = 0; i < theArray.length; i++) { + total += theArray[i] } return total; -} \ No newline at end of file +} + +console.log(sumTheElements([2,13,34,5])) From c8022448f13c7c2c9e5544e18a7bb14fe606ab3d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:13:30 +0200 Subject: [PATCH 43/94] Update README.md --- exercises/08.3-Sum-all-items/README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/exercises/08.3-Sum-all-items/README.md b/exercises/08.3-Sum-all-items/README.md index a12b0c3f..f93fa8ec 100644 --- a/exercises/08.3-Sum-all-items/README.md +++ b/exercises/08.3-Sum-all-items/README.md @@ -2,7 +2,9 @@ ## 📝 Instructions: -Using a `for` loop, complete the code of the function `sumTheElements` so that it returns the sum of all the items in a given array, for example: +1. Using a `for` loop, complete the code of the function `sumTheElements` so that it returns the sum of all the items in a given array. + +## 💻 Expected result: ```js console.log(sumTheElements([2,13,34,5])) @@ -13,16 +15,10 @@ console.log(sumTheElements([2,13,34,5])) + Initialize a variable `total` at 0. -+ Call the function with any array of numbers that add up to the expected result above. - + Loop the entire array inside of the function. + On every loop add the value of each item into the `total` variable. + Return the `total` variable (outside of the loop but inside of the function). -## 💻 Expected result: - -```js -54 -``` ++ Call the function with any array of numbers that add up to the expected result above `54`. From acced928c8de939079a117b59dc6de2c7f1b568a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:15:42 +0200 Subject: [PATCH 44/94] Update README.es.md --- exercises/08.3-Sum-all-items/README.es.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/exercises/08.3-Sum-all-items/README.es.md b/exercises/08.3-Sum-all-items/README.es.md index b8205bfa..361d1eca 100644 --- a/exercises/08.3-Sum-all-items/README.es.md +++ b/exercises/08.3-Sum-all-items/README.es.md @@ -1,15 +1,17 @@ -# `08.3` Suma todos los elementos +# `08.3` Sum All Items -## :pencil: Instrucciones: +## 📝 Instrucciones: -1. Usando un bucle (loop) `for`, completa el código de la función `sumTheElements` para que devuelva la suma de todos los elementos en un arreglo (array) dado, por ejemplo: +1. Usando un bucle (loop) `for`, completa el código de la función `sumTheElements` para que devuelva la suma de todos los elementos en un array dado. + +## 💻 Resultado esperado: ```js console.log(sumTheElements([2,13,34,5])) -//el resultado debiese ser 54 +// El resultado debe ser 54 ``` -## :bulb: Pista: +## 💡 Pista: + Inicializa una variable `total` en 0. @@ -19,8 +21,4 @@ console.log(sumTheElements([2,13,34,5])) + Devuelve la variable `total` (fuera del bucle pero dentro de la función). -### Resultado esperado: - -```js -54 -``` \ No newline at end of file ++ Llama la función con un arreglo cualquiera de números que sumados den el resultado esperado de arriba `54`. From 2a174aad164f6479aecddafcc35ddc6a4613f7c5 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:15:53 +0200 Subject: [PATCH 45/94] Update README.es.md --- exercises/08.3-Sum-all-items/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/08.3-Sum-all-items/README.es.md b/exercises/08.3-Sum-all-items/README.es.md index 361d1eca..ba12aff0 100644 --- a/exercises/08.3-Sum-all-items/README.es.md +++ b/exercises/08.3-Sum-all-items/README.es.md @@ -11,7 +11,7 @@ console.log(sumTheElements([2,13,34,5])) // El resultado debe ser 54 ``` -## 💡 Pista: +## 💡 Pistas: + Inicializa una variable `total` en 0. From 414e2881475418f0f04e7e0cbabd1d757f9d7f88 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:22:23 +0200 Subject: [PATCH 46/94] Update README.md --- exercises/09-forEach-loop/README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/exercises/09-forEach-loop/README.md b/exercises/09-forEach-loop/README.md index 5b7be44d..1feef4b1 100644 --- a/exercises/09-forEach-loop/README.md +++ b/exercises/09-forEach-loop/README.md @@ -1,28 +1,26 @@ # `09` forEach Loop -Instead of using the classic `for` statement, there is a new way to loop arrays called [higher order functions](https://www.youtube.com/watch?v=rRgD1yVwIvE). +Instead of using the classic `for` statement, there is a new way to loop arrays, called [higher order functions](https://www.youtube.com/watch?v=rRgD1yVwIvE). -It is possible to loop an array using the `array.forEach` function. You have to specify what to do on each iteration of the loop. +It is possible to loop an array using the `myArray.forEach()` function. You have to specify what to do on each iteration of the loop. ```js -myArray.forEach(function(item, index, arr){ +myArray.forEach(function(item, index, arr) { }); /** * item: will be the value of the specific item (required). - * index: will be the item index(optional). + * index: will be the item index (optional). * arr: will be the array object to which the element belongs to (optional). */ - - ``` -## :pencil: Instructions: +## 📝 Instructions: Right now, the code is printing all the items in the array: 1. Please change the function code to print only the numbers divisible by 14. -## :bulb: Hint: +## 💡 Hint: -A number X is divisible by 2 if: `(X%2===0)`. ++ A number x is divisible by 2 if: `(x % 2 === 0)`. From 32d8a070fc6bd057ebd9b73616d79b41b84c4e49 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:26:36 +0200 Subject: [PATCH 47/94] Update README.es.md --- exercises/09-forEach-loop/README.es.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/09-forEach-loop/README.es.md b/exercises/09-forEach-loop/README.es.md index 08c166a1..36203717 100644 --- a/exercises/09-forEach-loop/README.es.md +++ b/exercises/09-forEach-loop/README.es.md @@ -1,11 +1,11 @@ -# `09` Bucle/loop forEach +# `09` forEach Loop -En lugar de usar la clásica declaración `for`, hay una nueva forma de recorrer los arreglos: [ higher order functions (funciones de orden superior) ](https://www.youtube.com/watch?v=rRgD1yVwIvE) +En lugar de usar la clásica declaración `for`, hay una nueva forma de recorrer los arreglos: [higher order functions (funciones de orden superior)](https://www.youtube.com/watch?v=rRgD1yVwIvE). -Es posible recorrer un arreglo usando la función `array.forEach`. Debes especificar qué hacer en cada iteración del bucle. +Es posible recorrer un arreglo usando la función `myArray.forEach()`. Debes especificar qué hacer en cada iteración del bucle. ```js -myArray.forEach(function(item, index, arr){ +myArray.forEach(function(item, index, arr) { }); /** @@ -15,12 +15,12 @@ myArray.forEach(function(item, index, arr){ */ ``` -## :pencil: Instrucciones: +## 📝 Instrucciones: -En este momento, el código está imprimiendo todos los elementos en el arreglo o array: +En este momento, el código está imprimiendo todos los elementos en el array: 1. Cambia el código de la función para imprimir solo los números divisibles por 14. -## :bulb: Pista: +## 💡 Pista: -+ Un número X es divisible por 2 si `(X%2===0)`. \ No newline at end of file ++ Un número (x) es divisible por 2 si `(x % 2 === 0)`. From 19159e23009bdf2d0ffa6094881929e7ddee5423 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:27:54 +0200 Subject: [PATCH 48/94] Update README.md --- exercises/09-forEach-loop/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/09-forEach-loop/README.md b/exercises/09-forEach-loop/README.md index 1feef4b1..e3731023 100644 --- a/exercises/09-forEach-loop/README.md +++ b/exercises/09-forEach-loop/README.md @@ -23,4 +23,4 @@ Right now, the code is printing all the items in the array: ## 💡 Hint: -+ A number x is divisible by 2 if: `(x % 2 === 0)`. ++ A number (x) is divisible by 2 if: `(x % 2 === 0)`. From f0e74646cdf04c828122048f5f90260b4c0829c1 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:31:25 +0200 Subject: [PATCH 49/94] Update solution.hide.js --- exercises/09-forEach-loop/solution.hide.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/exercises/09-forEach-loop/solution.hide.js b/exercises/09-forEach-loop/solution.hide.js index 4b5327ec..3a2b01a6 100644 --- a/exercises/09-forEach-loop/solution.hide.js +++ b/exercises/09-forEach-loop/solution.hide.js @@ -1,9 +1,8 @@ let myArray = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343]; -myArray.forEach(function(item, index, arr){ +myArray.forEach(function(item, index, arr) { // The value of the item is if (item % 14 === 0) { console.log(item); } - -}); \ No newline at end of file +}); From 8bc30fb2c9d937cc64d1ec6493943702dd20bf3b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:31:31 +0200 Subject: [PATCH 50/94] Update app.js --- exercises/09-forEach-loop/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/09-forEach-loop/app.js b/exercises/09-forEach-loop/app.js index 51475751..18b3206d 100644 --- a/exercises/09-forEach-loop/app.js +++ b/exercises/09-forEach-loop/app.js @@ -1,6 +1,6 @@ let myArray = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343]; -myArray.forEach(function(item, index, arr){ +myArray.forEach(function(item, index, arr) { // The value of the item is console.log(item); -}); \ No newline at end of file +}); From afd019e2494c3091c6cb0b733eac2fef508a9b96 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:34:23 +0200 Subject: [PATCH 51/94] Update README.md --- exercises/10-Everything-is-awesome/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/10-Everything-is-awesome/README.md b/exercises/10-Everything-is-awesome/README.md index c20f715f..7b0d3671 100644 --- a/exercises/10-Everything-is-awesome/README.md +++ b/exercises/10-Everything-is-awesome/README.md @@ -4,7 +4,7 @@ 1. Compare the item. If it is `1` push the number to the array `return_array`. -2. Compare the item. If it is 0 push `Yahoo` to the array `return_array` (instead of the number) +2. Compare the item. If it is `0` push `'Yahoo'` to the array `return_array` (instead of the number). For example for `[0,0,1,1,0]` the output would be: From 459dcabe809fe7ee8c669d63f46794b6f884ff86 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:36:05 +0200 Subject: [PATCH 52/94] Update README.es.md --- exercises/10-Everything-is-awesome/README.es.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/10-Everything-is-awesome/README.es.md b/exercises/10-Everything-is-awesome/README.es.md index a2dff015..73455165 100644 --- a/exercises/10-Everything-is-awesome/README.es.md +++ b/exercises/10-Everything-is-awesome/README.es.md @@ -1,12 +1,12 @@ -# `10` Todo es increíble +# `10` Everything is awesome ## 📝 Instrucciones: 1. Compara el elemento. Si es `1`, pon el número en el arreglo `return_array`. -2. Compara el elemento. Si es `0`, pon `Yahoo` en el arreglo o array `return_array` (en lugar del número) +2. Compara el elemento. Si es `0`, pon `'Yahoo'` en el arreglo `return_array` (en lugar del número). -Por ejemplo la salida de `[0,0,1,1,0]` sería: +Por ejemplo, la salida de `[0,0,1,1,0]` sería: ```js ['Yahoo','Yahoo','1','1','Yahoo'] From 3b5af69c871e6a7f400842a7116c1e37443474e8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:41:48 +0200 Subject: [PATCH 53/94] Update solution.hide.js --- exercises/10-Everything-is-awesome/solution.hide.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/exercises/10-Everything-is-awesome/solution.hide.js b/exercises/10-Everything-is-awesome/solution.hide.js index d242f48f..8eebb636 100644 --- a/exercises/10-Everything-is-awesome/solution.hide.js +++ b/exercises/10-Everything-is-awesome/solution.hide.js @@ -4,11 +4,11 @@ let myArray = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ]; const ZerosToYahoos = (arr) => { let return_array = []; - arr.forEach((item,index) => { + arr.forEach((item) => { // magic goes inside these brackets return_array.push(item === 1 ? item : 'Yahoo') - }); + return return_array; }; @@ -20,17 +20,16 @@ let myArray2 = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ]; const ZerosToYahoos2 = (arr) => { let return_array = []; - arr.forEach((item,index) => { + arr.forEach((item) => { // magic goes inside these brackets if (item === 1) { return_array.push(item) - }else{ + } else { return_array.push('Yahoo') - } - }); + return return_array; }; -console.log(ZerosToYahoos2(myArray2)); \ No newline at end of file +console.log(ZerosToYahoos2(myArray2)); From 15248ced4f03930730b92802d2b3725663c53d8e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:42:11 +0200 Subject: [PATCH 54/94] Update app.js --- exercises/10-Everything-is-awesome/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/10-Everything-is-awesome/app.js b/exercises/10-Everything-is-awesome/app.js index 11f447a4..cc761072 100644 --- a/exercises/10-Everything-is-awesome/app.js +++ b/exercises/10-Everything-is-awesome/app.js @@ -2,10 +2,10 @@ let myArray = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ]; const ZerosToYahoos = (arr) => { let return_array = []; - arr.forEach((item,index) => { + arr.forEach((item) => { // magic goes inside these brackets }); return return_array; }; -console.log(ZerosToYahoos(myArray)); \ No newline at end of file +console.log(ZerosToYahoos(myArray)); From 359c2ffa7b07876e677bf778b729ba5b0261193d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:42:23 +0200 Subject: [PATCH 55/94] Update solution.hide.js --- exercises/10-Everything-is-awesome/solution.hide.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/exercises/10-Everything-is-awesome/solution.hide.js b/exercises/10-Everything-is-awesome/solution.hide.js index 8eebb636..4a547bac 100644 --- a/exercises/10-Everything-is-awesome/solution.hide.js +++ b/exercises/10-Everything-is-awesome/solution.hide.js @@ -8,7 +8,6 @@ const ZerosToYahoos = (arr) => { // magic goes inside these brackets return_array.push(item === 1 ? item : 'Yahoo') }); - return return_array; }; @@ -28,7 +27,6 @@ const ZerosToYahoos2 = (arr) => { return_array.push('Yahoo') } }); - return return_array; }; From e08557687ab97b8a6745f56d238026b3d58f7046 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:49:04 +0200 Subject: [PATCH 56/94] Update README.md --- exercises/10-Everything-is-awesome/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/10-Everything-is-awesome/README.md b/exercises/10-Everything-is-awesome/README.md index 7b0d3671..22500e0a 100644 --- a/exercises/10-Everything-is-awesome/README.md +++ b/exercises/10-Everything-is-awesome/README.md @@ -9,5 +9,5 @@ For example for `[0,0,1,1,0]` the output would be: ```js -['Yahoo','Yahoo','1','1','Yahoo'] +['Yahoo','Yahoo', 1, 1,'Yahoo'] ``` From 05d419a308baa3a7c07ec425e15e779ef8ef957a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:53:38 +0200 Subject: [PATCH 57/94] Update README.es.md --- exercises/10-Everything-is-awesome/README.es.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/exercises/10-Everything-is-awesome/README.es.md b/exercises/10-Everything-is-awesome/README.es.md index 73455165..22a1f421 100644 --- a/exercises/10-Everything-is-awesome/README.es.md +++ b/exercises/10-Everything-is-awesome/README.es.md @@ -2,12 +2,16 @@ ## 📝 Instrucciones: -1. Compara el elemento. Si es `1`, pon el número en el arreglo `return_array`. +1. Compara el elemento. Si es `1`, agrega el número en el arreglo `return_array`. -2. Compara el elemento. Si es `0`, pon `'Yahoo'` en el arreglo `return_array` (en lugar del número). +2. Compara el elemento. Si es `0`, agrega el string `'Yahoo'` en el arreglo `return_array` (en lugar del número). Por ejemplo, la salida de `[0,0,1,1,0]` sería: ```js -['Yahoo','Yahoo','1','1','Yahoo'] +['Yahoo','Yahoo', 1, 1,'Yahoo'] ``` + +## 💡 Pista: + ++ Cuando agregues el número `1` al nuevo array asegúrate de hacerlo como número y no como string. From 135e9c55b0c637eb5f614af12683063342f2facf Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:54:57 +0200 Subject: [PATCH 58/94] Update README.es.md --- exercises/10-Everything-is-awesome/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/10-Everything-is-awesome/README.es.md b/exercises/10-Everything-is-awesome/README.es.md index 22a1f421..c32d3020 100644 --- a/exercises/10-Everything-is-awesome/README.es.md +++ b/exercises/10-Everything-is-awesome/README.es.md @@ -14,4 +14,4 @@ Por ejemplo, la salida de `[0,0,1,1,0]` sería: ## 💡 Pista: -+ Cuando agregues el número `1` al nuevo array asegúrate de hacerlo como número y no como string. ++ Cuando agregues el número `1` al nuevo array, asegúrate de hacerlo como número y no como string. From e5865f665fe382988a76214b3fd4a31a5a2e8125 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:57:27 +0200 Subject: [PATCH 59/94] Update README.md --- exercises/10-Everything-is-awesome/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exercises/10-Everything-is-awesome/README.md b/exercises/10-Everything-is-awesome/README.md index 22500e0a..6d948de4 100644 --- a/exercises/10-Everything-is-awesome/README.md +++ b/exercises/10-Everything-is-awesome/README.md @@ -2,12 +2,16 @@ ## 📝 Instructions: -1. Compare the item. If it is `1` push the number to the array `return_array`. +1. Compare the item. If it's `1` push the number to the array `return_array`. -2. Compare the item. If it is `0` push `'Yahoo'` to the array `return_array` (instead of the number). +2. Compare the item. If it's `0` push the string `'Yahoo'` to the array `return_array` (instead of the number). For example for `[0,0,1,1,0]` the output would be: ```js ['Yahoo','Yahoo', 1, 1,'Yahoo'] ``` + +## 💡 Hint: + ++ When you push the number `1` to the new array, make sure you push it as a number and not as a string. From 41c2ab6b937ff71daeb5ee067a37a49683de2b22 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:58:47 +0200 Subject: [PATCH 60/94] Update README.md --- exercises/10-Everything-is-awesome/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/10-Everything-is-awesome/README.md b/exercises/10-Everything-is-awesome/README.md index 6d948de4..e526a7da 100644 --- a/exercises/10-Everything-is-awesome/README.md +++ b/exercises/10-Everything-is-awesome/README.md @@ -6,7 +6,7 @@ 2. Compare the item. If it's `0` push the string `'Yahoo'` to the array `return_array` (instead of the number). -For example for `[0,0,1,1,0]` the output would be: +For example, for `[0,0,1,1,0]` the output would be: ```js ['Yahoo','Yahoo', 1, 1,'Yahoo'] From d842f1340f4d9a242dc85628c4030ea8ce92a4fb Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:06:22 +0200 Subject: [PATCH 61/94] Update README.md --- exercises/11-Do-while/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exercises/11-Do-while/README.md b/exercises/11-Do-while/README.md index 6fbfc838..02287092 100644 --- a/exercises/11-Do-while/README.md +++ b/exercises/11-Do-while/README.md @@ -1,9 +1,9 @@ # `11` DO DO DO -The `do{}while()`; is another loop example in javascript is less commonly used but it is a loop. +The `do{}while()`; is another loop statement in JavaScript that is less commonly used, but it's still a loop. ```js -// stating value for the loop: +// starting value for the loop: let i = 0; // the loop will do everything inside of the do code block @@ -24,8 +24,7 @@ do { 3. When the loop reaches zero, print `LIFTOFF` instead of `0`. This `console.log()` statement must go **inside** of the loop. - -### Expected result: +## 💻 Expected result: ```js 20! From 882f8c5b4900809ef76af1a44048cb7eeed0193c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:14:16 +0200 Subject: [PATCH 62/94] Update README.md --- exercises/11-Do-while/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/11-Do-while/README.md b/exercises/11-Do-while/README.md index 02287092..0d74fef2 100644 --- a/exercises/11-Do-while/README.md +++ b/exercises/11-Do-while/README.md @@ -20,7 +20,7 @@ do { 1. Print every iteration number on the console from 20 to 0. -2. Print the numbers that are module of 5 with a concatenated exclamation mark. +2. Print the numbers that are module of 5 with a concatenated exclamation mark `!`. 3. When the loop reaches zero, print `LIFTOFF` instead of `0`. This `console.log()` statement must go **inside** of the loop. From ec4b0c7b86c85cba561fba19eb11707909d43e1f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:17:57 +0200 Subject: [PATCH 63/94] Update README.es.md --- exercises/11-Do-while/README.es.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/exercises/11-Do-while/README.es.md b/exercises/11-Do-while/README.es.md index d18b1a19..4bd58473 100644 --- a/exercises/11-Do-while/README.es.md +++ b/exercises/11-Do-while/README.es.md @@ -1,9 +1,9 @@ # `11` DO DO DO -El `do{}while()`; es otro ejemplo de bucle(loop) en javascript que se usa con menos frecuencia pero es un bucle. +El `do{}while()`; es otra declaracion de bucle en JavaScript que se usa con menos frecuencia, pero es un bucle. ```js -// declarando el valor para el loop o bucle: +// declarando el valor inicial para el loop: let i = 0; // el loop hará todo dentro del bloque de código @@ -18,11 +18,13 @@ do { ## 📝 Instrucciones: -1. Imprime cada número de la iteración en la consola del 20 al 0, pero concaténale un signo de exclamación(`!`) al elemento si el número es un múltiplo de 5. +1. Imprime cada número de la iteración en la consola del 20 al 0. -2. Al final haz un `console.log()`de `LIFTOFF` +2. Si el número es un múltiplo de 5, concaténale un signo de exclamación `!` al elemento. -### Resultado esperado: +3. Cuando el bucle llegue a cero, imprime `LIFTOFF` en vez del número `0`. Esta instrucción debe ir también dentro del bucle. + +## 💻 Resultado esperado: ```js 20! @@ -38,5 +40,6 @@ do { 10! . . +1 LIFTOFF ``` From aff95337e6ca4ce1633dc608eb379b316692c247 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:36:41 +0200 Subject: [PATCH 64/94] Update test.js --- exercises/11-Do-while/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/11-Do-while/test.js b/exercises/11-Do-while/test.js index fc9653fd..62519b5b 100644 --- a/exercises/11-Do-while/test.js +++ b/exercises/11-Do-while/test.js @@ -8,7 +8,7 @@ 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 do-while function', () => { +test('You have to use the do...while function', () => { const file = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); const regex = /do\s*/gm expect(regex.test(file.toString())).toBeTruthy(); From c0846a8680a458203ba8b638822985c415e5e14d Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:36:58 +0200 Subject: [PATCH 65/94] Update test.js --- exercises/11-Do-while/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/11-Do-while/test.js b/exercises/11-Do-while/test.js index 62519b5b..058cc6bc 100644 --- a/exercises/11-Do-while/test.js +++ b/exercises/11-Do-while/test.js @@ -14,7 +14,7 @@ test('You have to use the do...while function', () => { expect(regex.test(file.toString())).toBeTruthy(); }) -it("The output should match the one in the instructions", function () { +it('The output should match the one in the instructions', function () { const app = require('./app.js'); let _output = []; From 4203fa50ab25543e836598476e366cd8c0571df3 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:39:16 +0200 Subject: [PATCH 66/94] Update solution.hide.js --- exercises/11-Do-while/solution.hide.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/exercises/11-Do-while/solution.hide.js b/exercises/11-Do-while/solution.hide.js index 96107a23..52fc1243 100644 --- a/exercises/11-Do-while/solution.hide.js +++ b/exercises/11-Do-while/solution.hide.js @@ -1,12 +1,11 @@ let i = 20; do { - // Magic goes here; + // Magic goes here if (i % 5 === 0) { - console.log(i + "!") - // console.log(i+"!") + console.log(i + "!"); } - else { console.log(i) } + else { console.log(i) }; i--; } while (i > 0); -console.log("LIFTOFF") \ No newline at end of file +console.log("LIFTOFF") From 71a785a6f0350783f3a4cdd6459e310e8f33e8b0 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:39:36 +0200 Subject: [PATCH 67/94] Update solution.hide.js --- exercises/11-Do-while/solution.hide.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/11-Do-while/solution.hide.js b/exercises/11-Do-while/solution.hide.js index 52fc1243..8bfbf8b8 100644 --- a/exercises/11-Do-while/solution.hide.js +++ b/exercises/11-Do-while/solution.hide.js @@ -8,4 +8,4 @@ do { else { console.log(i) }; i--; } while (i > 0); -console.log("LIFTOFF") +console.log("LIFTOFF"); From b7b293a8b3104ffdd86ac100b31d2dbf8352f737 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:40:50 +0200 Subject: [PATCH 68/94] Update app.js --- exercises/11-Do-while/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/11-Do-while/app.js b/exercises/11-Do-while/app.js index 0db3f713..e210a581 100644 --- a/exercises/11-Do-while/app.js +++ b/exercises/11-Do-while/app.js @@ -1,7 +1,7 @@ let i = 20; do { - // Magic goes here; + // Magic goes here i--; -} while (i > 0); \ No newline at end of file +} while (i > 0); From 157442a57906b8c999dafbef5e9e6f4dca5efc3c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:43:28 +0200 Subject: [PATCH 69/94] Update solution.hide.js --- exercises/11-Do-while/solution.hide.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/exercises/11-Do-while/solution.hide.js b/exercises/11-Do-while/solution.hide.js index 8bfbf8b8..3bbc3830 100644 --- a/exercises/11-Do-while/solution.hide.js +++ b/exercises/11-Do-while/solution.hide.js @@ -1,11 +1,13 @@ let i = 20; do { - // Magic goes here - if (i % 5 === 0) { - console.log(i + "!"); + // Magic goes here; + if (i === 0) { + console.log("LIFTOFF") + } else if (i % 5 === 0) { + console.log(i + "!") + } else { + console.log(i) } - else { console.log(i) }; i--; -} while (i > 0); -console.log("LIFTOFF"); +} while (i >= 0); From 3d6cba7a8c2d9bafc668299bb17d997c72caa582 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:43:36 +0200 Subject: [PATCH 70/94] Update app.js --- exercises/11-Do-while/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/11-Do-while/app.js b/exercises/11-Do-while/app.js index e210a581..d14baa15 100644 --- a/exercises/11-Do-while/app.js +++ b/exercises/11-Do-while/app.js @@ -4,4 +4,4 @@ do { // Magic goes here i--; -} while (i > 0); +} while (i >= 0); From 9a1889d2986109994f3ffd34bce7cca53df03643 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:44:41 +0200 Subject: [PATCH 71/94] Update solution.hide.js --- exercises/11-Do-while/solution.hide.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/11-Do-while/solution.hide.js b/exercises/11-Do-while/solution.hide.js index 3bbc3830..813b9c44 100644 --- a/exercises/11-Do-while/solution.hide.js +++ b/exercises/11-Do-while/solution.hide.js @@ -1,13 +1,13 @@ let i = 20; do { - // Magic goes here; + // Magic goes here if (i === 0) { - console.log("LIFTOFF") + console.log("LIFTOFF"); } else if (i % 5 === 0) { - console.log(i + "!") + console.log(i + "!"); } else { - console.log(i) + console.log(i); } i--; } while (i >= 0); From 82d31097bc4cde1209d00204cfd1f5e24d2e6d6a Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 21:53:49 +0200 Subject: [PATCH 72/94] Update README.md --- exercises/12-Delete-element/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/exercises/12-Delete-element/README.md b/exercises/12-Delete-element/README.md index f27fa6a0..7748e43a 100644 --- a/exercises/12-Delete-element/README.md +++ b/exercises/12-Delete-element/README.md @@ -2,9 +2,9 @@ One of the ways to delete `Daniella` from the array (without cheating) will be to create a new list with all the other people but `Daniella`. -That happens to be the default behavior of the `array.filter()` method which you should know. Similar to the `array.forEach()` and `array.map()` methods, it is a higher-order function, which means that it calls another function to achieve its goals. +That happens to be the default behavior of the `array.filter()` method, which you should know. Similar to the `array.forEach()` and `array.map()` methods, it is a higher-order function, which means that it calls another function to achieve its goals. -That secondary **callback** function is called by the `array.filter()` with up to three parameters (which are optional) and the returned value can only be one thing - a condition: +That secondary **callback** function is called by the `array.filter()` with up to three parameters (which are optional), and the returned value can only be one thing - a condition: ```js (elementBeingIterated, indexOfThatElement, theIteratedArray) => condition; @@ -21,14 +21,13 @@ console.log(newArray); // outcome is [2, 4, 2, 4] The `array.filter()` method automatically creates a new array in which only the elements that pass the condition are kept. Any other elements are dropped from the `newArray`. -You can learn more about this method [here](https://www.w3schools.com/jsref/jsref_filter.asp) +You can learn more about this method [here](https://www.w3schools.com/jsref/jsref_filter.asp). -## Instructions: +## 📝 Instructions: 1. Please create a `deletePerson` function that "deletes" any given person from an array and returns a new array without that person. - -## Expected result: +## 💻 Expected result: ```js ['juan', 'ana', 'michelle', 'stefany', 'lucy', 'barak', 'emilio'] From 3528ca1fcec7534b4f92311b60de4b84dc2cea8f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:03:56 +0200 Subject: [PATCH 73/94] Update README.es.md --- exercises/12-Delete-element/README.es.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/12-Delete-element/README.es.md b/exercises/12-Delete-element/README.es.md index edfdb35c..2192e406 100644 --- a/exercises/12-Delete-element/README.es.md +++ b/exercises/12-Delete-element/README.es.md @@ -1,16 +1,16 @@ # `12` Eliminar el elemento -La única forma de eliminar a `Daniella` del array o arreglo (sin hacer trampa) es crear un nuevo arreglo con todas las demás personas, excepto `Daniella`. +La única forma de eliminar a `Daniella` del array (sin hacer trampa) es crear un nuevo array con todas las demás personas, excepto `Daniella`. Así se comporta el método `array.filter()`. Similar a los métodos `array.forEach()` y `array.map()`, es una función de orden superior, lo que significa que llama a otra función para lograr sus objetivos. -Esa funcion **callback** (de retorno) se llama `array.filter()` que acepta hasta 3 parámetros (opcionales) y el valor devuelto solo puede ser una cosa - una condición: +Esa función secundaria es llamada por `array.filter()` que acepta hasta 3 parámetros (opcionales) y el valor devuelto solo puede ser una cosa - una condición: ```js (elementBeingIterated, indexOfThatElement, theIteratedArray) => condition; ``` -Asi que si quieres quedarte solo con los números 2 y 4 del array o arreglo de números, tu método `array.filter()` se vería de esta forma: +Así que si quieres quedarte solo con los números 2 y 4 del array de números, tu método `array.filter()` se vería de esta forma: ```js let array = [2, 9, 5, 6, 4, 1, 2, 3, 4]; @@ -19,18 +19,18 @@ let newArray = array.filter((element) => element === 2 || element === 4); console.log(newArray); // resultado es [2, 4, 2, 4] ``` -El método `array.filter()` automáticamente crea un nuevo array o arreglo (`newArray`) en el cual solo están los elementos que cumplan con la condición. El resto de los elements quedan fuera del `newArray`. +El método `array.filter()` automáticamente crea un nuevo array en el cual solo están los elementos que cumplan con la condición. El resto de los elements quedan fuera del `newArray`. Puedes aprender más sobre este método [aquí](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) -## 📝Instrucciones: +## 📝 Instrucciones: 1. Crea una función `deletePerson` que "elimine" a cualquier persona del arreglo y devuelva un nuevo arreglo sin esa persona. -## Resultado esperado: +## 💻 Resultado esperado: ```js - ['juan', 'ana', 'michelle', 'stefany', 'lucy', 'barak'] -['ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak'] +['juan', 'ana', 'michelle', 'stefany', 'lucy', 'barak', 'emilio'] +['ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak', 'emilio'] ['juan', 'ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak'] ``` From 96db7667e13101951dafe16de61b05a1fcd0fecb Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:04:08 +0200 Subject: [PATCH 74/94] Update README.es.md --- exercises/12-Delete-element/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/12-Delete-element/README.es.md b/exercises/12-Delete-element/README.es.md index 2192e406..b518ae7f 100644 --- a/exercises/12-Delete-element/README.es.md +++ b/exercises/12-Delete-element/README.es.md @@ -19,7 +19,7 @@ let newArray = array.filter((element) => element === 2 || element === 4); console.log(newArray); // resultado es [2, 4, 2, 4] ``` -El método `array.filter()` automáticamente crea un nuevo array en el cual solo están los elementos que cumplan con la condición. El resto de los elements quedan fuera del `newArray`. +El método `array.filter()` automáticamente crea un nuevo array en el cual solo están los elementos que cumplan con la condición. El resto de los elementos quedan fuera del `newArray`. Puedes aprender más sobre este método [aquí](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) From e8161a65413ae7afef8ac5c13469ea010403bdb6 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:04:32 +0200 Subject: [PATCH 75/94] Update README.es.md --- exercises/12-Delete-element/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/12-Delete-element/README.es.md b/exercises/12-Delete-element/README.es.md index b518ae7f..37f67fa5 100644 --- a/exercises/12-Delete-element/README.es.md +++ b/exercises/12-Delete-element/README.es.md @@ -21,7 +21,7 @@ console.log(newArray); // resultado es [2, 4, 2, 4] El método `array.filter()` automáticamente crea un nuevo array en el cual solo están los elementos que cumplan con la condición. El resto de los elementos quedan fuera del `newArray`. -Puedes aprender más sobre este método [aquí](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) +Puedes aprender más sobre este método [aquí](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). ## 📝 Instrucciones: From f569b3c89ecd25ccc8226dcea1ee62cff7e44fad Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:05:27 +0200 Subject: [PATCH 76/94] Update app.js --- exercises/12-Delete-element/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/12-Delete-element/app.js b/exercises/12-Delete-element/app.js index 1bdb10ab..d267b379 100644 --- a/exercises/12-Delete-element/app.js +++ b/exercises/12-Delete-element/app.js @@ -1,6 +1,6 @@ let people = ['juan','ana','michelle','daniella','stefany','lucy','barak', 'emilio']; -//your code below +// Your code below console.log(deletePerson('daniella')); console.log(deletePerson('juan')); From 5a8f5f6d531dfa91639e35a8147dde8f57e2626f Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:07:27 +0200 Subject: [PATCH 77/94] Update solution.hide.js --- exercises/12-Delete-element/solution.hide.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/exercises/12-Delete-element/solution.hide.js b/exercises/12-Delete-element/solution.hide.js index 2a7c812d..77feb614 100644 --- a/exercises/12-Delete-element/solution.hide.js +++ b/exercises/12-Delete-element/solution.hide.js @@ -1,10 +1,11 @@ let people = ['juan','ana','michelle','daniella','stefany','lucy','barak', 'emilio']; -//your code below -function deletePerson(name){ +// Your code below +function deletePerson(name) { let peopleArray = people.filter((person) => person != name) return peopleArray } + console.log(deletePerson('daniella')); console.log(deletePerson('juan')); -console.log(deletePerson('emilio')); \ No newline at end of file +console.log(deletePerson('emilio')); From b791339546b84fa0d7b6b872b77ffe84c0d587b8 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:09:39 +0200 Subject: [PATCH 78/94] Update test.js --- exercises/12-Delete-element/test.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/exercises/12-Delete-element/test.js b/exercises/12-Delete-element/test.js index 8daa4997..13ae5e5b 100644 --- a/exercises/12-Delete-element/test.js +++ b/exercises/12-Delete-element/test.js @@ -15,17 +15,19 @@ test('The array "people" should exist', () => { const file = rewire("./app.js"); const people = file.__get__("people"); expect(people).not.toBe(undefined); -}) +}); + test('"daniella" should exist in the "people" array', () => { const file = rewire("./app.js"); const people = file.__get__("people"); expect(people[3]).toBe('daniella'); -}) +}); + test('"juan" should exist in the "people" array', () => { const file = rewire("./app.js"); const people = file.__get__("people"); expect(people[0]).toBe('juan'); -}) +}); test("Function deletePerson should exist", function () { expect(deletePerson).toBeTruthy(); @@ -34,22 +36,24 @@ test("Function deletePerson should exist", function () { test("Function deletePerson should return something", function () { expect(deletePerson()).not.toBe(undefined) }); + test('console.log() function should have been called 3 times', function () { //then I import the index.js (which should have the alert() call inside) const file = require("./app.js"); expect(console.log.mock.calls.length).toBe(3); }); -test("If you call the deletePerson function with the name daniella, she cannot appear in the new list.", function () { +test("If you call the deletePerson function with the name daniella, she cannot appear in the new list", function () { // expect(console.log).toHaveBeenCalledWith(deletePerson('daniella')) expect(deletePerson('daniella')).not.toContain('daniella'); }); -test("If you call the deletePerson function with the name juan, he cannot appear in the new list.", function () { + +test("If you call the deletePerson function with the name juan, he cannot appear in the new list", function () { // expect(console.log).toHaveBeenCalledWith(deletePerson('juan')) expect(deletePerson('juan')).not.toContain('juan'); }); -test("If you call the deletePerson function with the name emilio, he cannot appear in the new list.", function () { +test("If you call the deletePerson function with the name emilio, he cannot appear in the new list", function () { // expect(console.log).toHaveBeenCalledWith(deletePerson('emilio')) expect(deletePerson('emilio')).not.toContain('emilio'); }); From 3be070ca1c425f8e27d6edc2360a05de77649654 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:10:43 +0200 Subject: [PATCH 79/94] Update README.es.md --- exercises/12-Delete-element/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/12-Delete-element/README.es.md b/exercises/12-Delete-element/README.es.md index 37f67fa5..74a5889b 100644 --- a/exercises/12-Delete-element/README.es.md +++ b/exercises/12-Delete-element/README.es.md @@ -1,4 +1,4 @@ -# `12` Eliminar el elemento +# `12` Delete element La única forma de eliminar a `Daniella` del array (sin hacer trampa) es crear un nuevo array con todas las demás personas, excepto `Daniella`. From f3a07e925a1cd9601a23064db86176c45a99c93e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:14:25 +0200 Subject: [PATCH 80/94] Update README.es.md --- exercises/13-Merge-arrays/README.es.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/13-Merge-arrays/README.es.md b/exercises/13-Merge-arrays/README.es.md index 23a34338..c42394df 100644 --- a/exercises/13-Merge-arrays/README.es.md +++ b/exercises/13-Merge-arrays/README.es.md @@ -1,16 +1,16 @@ -# `13` Uniendo arrays: +# `13` Merging arrays -En este ejercicio vamos a combinar dos arreglos programaticamente. +En este ejercicio vamos a unir dos arreglos programáticamente. -## 📝Instrucciones: +## 📝 Instrucciones: -Escribe una función que combine dos arreglos y retorne un único arreglo nuevo que combine todos los valores de ambos arreglos en un solo arreglo. +1. Escribe una función que combine dos arreglos y retorne un único arreglo nuevo que combine todos los valores de ambos arreglos en un solo arreglo. -### 💡 Pista: +## 💡 Pista: + Tendrás que recorrer cada arreglo e insertar sus elementos en un nuevo arreglo. -### Resultado esperado: +## 💻 Resultado esperado: ```js ['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas'] From e0ef0b1e5c551f5f926567e13c19484a1e9c3dd4 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:37:07 +0200 Subject: [PATCH 81/94] Update README.es.md --- exercises/13-Merge-arrays/README.es.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/exercises/13-Merge-arrays/README.es.md b/exercises/13-Merge-arrays/README.es.md index c42394df..1cb73ff5 100644 --- a/exercises/13-Merge-arrays/README.es.md +++ b/exercises/13-Merge-arrays/README.es.md @@ -4,14 +4,19 @@ En este ejercicio vamos a unir dos arreglos programáticamente. ## 📝 Instrucciones: -1. Escribe una función que combine dos arreglos y retorne un único arreglo nuevo que combine todos los valores de ambos arreglos en un solo arreglo. - -## 💡 Pista: - -+ Tendrás que recorrer cada arreglo e insertar sus elementos en un nuevo arreglo. +1. Escribe una función que combine dos arrays y retorne un único array nuevo, con todos los elementos de ambos arrays. +2. Asegúrate de no crear un array con 2 arrays anidados. Debe ser un solo array con todos los nombres en su orden original. ## 💻 Resultado esperado: ```js - ['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas'] +['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas'] ``` + +## 💡 Pistas: + ++ Puedes encontrar más información sobre diferentes formas de unir arrays [aquí](https://www.techiedelight.com/es/merge-elements-two-arrays-javascript/). + ++ Si tienes dificultades para evitar obtener un array anidado, echa un vistazo al concepto del [operador de propagación de JavaScript.](https://www.educative.io/edpresso/what-is-the-spread-operator-in-javascript). + ++ Tendrás que recorrer cada arreglo e insertar sus elementos en un nuevo arreglo. From c232c549fc5990d386560913daf28ab3da32d84c Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:37:11 +0200 Subject: [PATCH 82/94] Update README.md --- exercises/13-Merge-arrays/README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/exercises/13-Merge-arrays/README.md b/exercises/13-Merge-arrays/README.md index 300b349c..529b9d46 100644 --- a/exercises/13-Merge-arrays/README.md +++ b/exercises/13-Merge-arrays/README.md @@ -1,28 +1,23 @@ -# `13` Merging arrays: +# `13` Merging arrays +In this exercise we will learn how to merge two arrays. -In this exercise we will learn how to combine two arrays. - - -## 📝Instructions: +## 📝 Instructions: 1. Write a function that merges and returns the two arrays into a single new array, with all the items from both arrays inside. 2. Be sure not to create an array with two nested arrays. It should be a single array with all the names in their original order. -3. Find out why you souldn't use the `.push()` method? -## 💡 Hint: - -+ You will have to loop through each array and insert their items into a new array. - -## Expected result: +## 💻 Expected result: ```js - ['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas'] +['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas'] ``` -### 💡 Hint: +## 💡 Hints: + ++ You can find more information on the different ways to merge arrays [here](https://dmitripavlutin.com/javascript-merge-arrays/). -+ You can find more information on the different ways to merge arrays [here](https://dmitripavlutin.com/javascript-merge-arrays/) ++ If you are struggling with preventing getting a nested array, take a look at the concept of the JS [spread operator](https://www.educative.io/edpresso/what-is-the-spread-operator-in-javascript). -+ If you are struggling with preventing getting a nested array, take a look at the concept of the JS [spread operator](https://www.educative.io/edpresso/what-is-the-spread-operator-in-javascript) ++ You will have to loop through each array and insert their items into a new array. From 163e82e56e55076b0db5f90a1d0f63bb31cfbf7b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:38:08 +0200 Subject: [PATCH 83/94] Update README.es.md --- exercises/13-Merge-arrays/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/13-Merge-arrays/README.es.md b/exercises/13-Merge-arrays/README.es.md index 1cb73ff5..2d71886c 100644 --- a/exercises/13-Merge-arrays/README.es.md +++ b/exercises/13-Merge-arrays/README.es.md @@ -17,6 +17,6 @@ En este ejercicio vamos a unir dos arreglos programáticamente. + Puedes encontrar más información sobre diferentes formas de unir arrays [aquí](https://www.techiedelight.com/es/merge-elements-two-arrays-javascript/). -+ Si tienes dificultades para evitar obtener un array anidado, echa un vistazo al concepto del [operador de propagación de JavaScript.](https://www.educative.io/edpresso/what-is-the-spread-operator-in-javascript). ++ Si tienes dificultades para evitar obtener un array anidado, echa un vistazo al concepto del [operador de propagación de JavaScript](https://www.educative.io/edpresso/what-is-the-spread-operator-in-javascript). + Tendrás que recorrer cada arreglo e insertar sus elementos en un nuevo arreglo. From fcf8b3842eb0fac0c1f05a39788a61aaa84e0b48 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:39:33 +0200 Subject: [PATCH 84/94] Update app.js --- exercises/13-Merge-arrays/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/13-Merge-arrays/app.js b/exercises/13-Merge-arrays/app.js index cffbcdd4..47227125 100644 --- a/exercises/13-Merge-arrays/app.js +++ b/exercises/13-Merge-arrays/app.js @@ -1,10 +1,10 @@ -let chunk_one = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ]; -let chunk_two = [ 'Lucas' , 'Jake','Scott','Amy', 'Molly','Hannah','Lucas']; +let chunkOne = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ]; +let chunkTwo = [ 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas' ]; const mergeArrays = (firstArray, secondArray) => { let newArray = [] - //your code here + // Your code here return newArray } -console.log(mergeArrays(chunk_one, chunk_two)); \ No newline at end of file +console.log(mergeArrays(chunkOne, chunkTwo)); From 6ad468f901e6491ff58e964debcb5c7c268bc033 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:41:26 +0200 Subject: [PATCH 85/94] Update solution.hide.js --- exercises/13-Merge-arrays/solution.hide.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/13-Merge-arrays/solution.hide.js b/exercises/13-Merge-arrays/solution.hide.js index fdc16b4a..25bf8258 100644 --- a/exercises/13-Merge-arrays/solution.hide.js +++ b/exercises/13-Merge-arrays/solution.hide.js @@ -1,21 +1,21 @@ -let chunk_one = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ]; -let chunk_two = [ 'Lucas' , 'Jake','Scott','Amy', 'Molly','Hannah','Lucas']; +let chunkOne = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ]; +let chunkTwo = [ 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas' ]; const mergeArrays = (firstArray, secondArray) => { - // this array with contain items from both original arrays + // This array will contain items from both original arrays let newArray = [] - // loop the first array and add each item to newArray + // Loop the first array and push each item to newArray firstArray.forEach(item => { newArray.push(item) }) - // loop the SECOND array and add each item to newArray + // Loop the second array and push each item to newArray secondArray.forEach(item => { newArray.push(item) }) - //return merged array + // return merged array return newArray } -console.log(mergeArrays(chunk_one, chunk_two)); \ No newline at end of file +console.log(mergeArrays(chunkOne, chunkTwo)); From a803a0f069c7388218efc7bde2aa7aee8a92a84b Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:43:21 +0200 Subject: [PATCH 86/94] Update test.js --- exercises/13-Merge-arrays/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/13-Merge-arrays/test.js b/exercises/13-Merge-arrays/test.js index 145b33eb..55746fd0 100644 --- a/exercises/13-Merge-arrays/test.js +++ b/exercises/13-Merge-arrays/test.js @@ -13,7 +13,7 @@ test("Function mergeArrays should exist", function(){ const mergeArrays = file.__get__('mergeArrays'); expect(mergeArrays).toBeTruthy(); }); -it('The returned array must contain everything item from firstArray', function () { +it('The returned array must contain every item from firstArray', function () { const _app = rewire('./app.js'); const mergeArrays = _app.__get__('mergeArrays'); @@ -22,7 +22,7 @@ it('The returned array must contain everything item from firstArray', function ( const arrTest = mergeArrays(_chunk_one,_chunk_two); expect(arrTest).toEqual(expect.arrayContaining(_chunk_one)); }); -it('The returned array must contain everything item from secondArray', function () { +it('The returned array must contain every item from secondArray', function () { const _app = rewire('./app.js'); const mergeArrays = _app.__get__('mergeArrays'); From d24aefcaf71a387b72833958e3500b50885cdd70 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:57:29 +0200 Subject: [PATCH 87/94] Update README.md --- exercises/14-Divide-and-Conquer/README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/14-Divide-and-Conquer/README.md b/exercises/14-Divide-and-Conquer/README.md index c54db69e..ec27171c 100644 --- a/exercises/14-Divide-and-Conquer/README.md +++ b/exercises/14-Divide-and-Conquer/README.md @@ -4,25 +4,25 @@ 1. Create a function called `mergeTwoList` that expects an array of numbers (integers). -2. Loop through the array and separate the odd and the even numbers in different arrays. +2. Loop through the array and separate the **odd** and the **even** numbers in different arrays. -3. If the number is odd number push it to a placeholder array named `odd`. +3. If the number is odd, push it to a placeholder array named `odd`. -4. If the number is even number push it to a placeholder array named `even`. +4. If the number is even, push it to a placeholder array named `even`. -5. The function should return a new array that contains both odd and even elements. +5. The function should return a new array that contains both `odd` and `even` elements in that order. + > Remember, the `odd` array comes first and you have to append the `even` array to it. Use the `.concat()` method. - -Example: +For example: ```js -mergeTwoList([1,2,33,10,20,4]) +mergeTwoList([1,2,33,10,20,4]); -// expected console output +// expected console output: [1, 33, 2, 10, 20, 4] ``` -### 💡 Hint: +## 💡 Hint: + Create local empty ***placeholder*** or ***auxiliary*** variables when you need to store data in a function. From 1bdab775cd3bc8e42eadfae1050fdaa4af558c01 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:57:32 +0200 Subject: [PATCH 88/94] Update README.es.md --- exercises/14-Divide-and-Conquer/README.es.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exercises/14-Divide-and-Conquer/README.es.md b/exercises/14-Divide-and-Conquer/README.es.md index fc47e7dc..a294ad2d 100644 --- a/exercises/14-Divide-and-Conquer/README.es.md +++ b/exercises/14-Divide-and-Conquer/README.es.md @@ -1,20 +1,20 @@ -# `14` Divide y conquista +# `14` Divide and conquer ## 📝 Instrucciones: 1. Crea una función llamada `mergeTwoList` que reciba un arreglo de números (enteros). -2. Recorre el arreglo y separa los números pares e impares en diferentes arreglos. +2. Recorre el arreglo y separa los números **pares** e **impares** en diferentes arreglos. 3. Si el número es impar, envíalo a un arreglo denominado `odd`. 4. Si el número es par, envíalo a un arreglo denominado `even`. -5. Luego concatena el arreglo `odd` al arreglo `even` para combinarlos. +5. La función debe retornar un nuevo arreglo que contenga los elementos de ambos arreglos `odd` y `even` en ese orden. > Recuerda que el arreglo `odd` va primero y luego debes agregar los items del arreglo `even` usando el método `.concat()`. -Ejemplo: +Por ejemplo: ```js mergeTwoList([1,2,33,10,20,4]); @@ -23,6 +23,6 @@ mergeTwoList([1,2,33,10,20,4]); [1, 33, 2, 10, 20, 4] ``` -### 💡 Pista: +## 💡 Pista: -+ Crea variables vacías cuando necesites almacenar datos. \ No newline at end of file ++ Crea variables locales vacías o ***auxiliares*** cuando necesites almacenar datos dentro de una función. From 5e30d8cd3aafad9696617de222d13dec86b982a6 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:58:46 +0200 Subject: [PATCH 89/94] Update README.md --- exercises/14-Divide-and-Conquer/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/14-Divide-and-Conquer/README.md b/exercises/14-Divide-and-Conquer/README.md index ec27171c..8e15fa69 100644 --- a/exercises/14-Divide-and-Conquer/README.md +++ b/exercises/14-Divide-and-Conquer/README.md @@ -25,4 +25,4 @@ mergeTwoList([1,2,33,10,20,4]); ## 💡 Hint: -+ Create local empty ***placeholder*** or ***auxiliary*** variables when you need to store data in a function. ++ Create local empty ***placeholders*** or ***auxiliary*** variables when you need to store data in a function. From 12ce3b0e63e6e703322de36b03d72785ad503390 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 22:59:45 +0200 Subject: [PATCH 90/94] Update README.es.md --- exercises/14-Divide-and-Conquer/README.es.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/14-Divide-and-Conquer/README.es.md b/exercises/14-Divide-and-Conquer/README.es.md index a294ad2d..c7777ae4 100644 --- a/exercises/14-Divide-and-Conquer/README.es.md +++ b/exercises/14-Divide-and-Conquer/README.es.md @@ -25,4 +25,4 @@ mergeTwoList([1,2,33,10,20,4]); ## 💡 Pista: -+ Crea variables locales vacías o ***auxiliares*** cuando necesites almacenar datos dentro de una función. ++ Crea variables vacías o ***auxiliares*** cuando necesites almacenar datos dentro de una función. From c4da8f29e2405f13891a20b68d5dbd926ff6ff93 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:00:17 +0200 Subject: [PATCH 91/94] Update app.js --- exercises/14-Divide-and-Conquer/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/14-Divide-and-Conquer/app.js b/exercises/14-Divide-and-Conquer/app.js index 82615a19..97665881 100644 --- a/exercises/14-Divide-and-Conquer/app.js +++ b/exercises/14-Divide-and-Conquer/app.js @@ -1,3 +1,3 @@ -let list_of_numbers = [4, 80, 85, 59, 37,25, 5, 64, 66, 81,20, 64, 41, 22, 76,76, 55, 96, 2, 68]; +let listOfNumbers = [4, 80, 85, 59, 37, 25, 5, 64, 66, 81, 20, 64, 41, 22, 76, 76, 55, 96, 2, 68]; -// your code here +// Your code here From 913c75f543db843317e528273f3065001185871e Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:01:49 +0200 Subject: [PATCH 92/94] Update app.js --- exercises/14-Divide-and-Conquer/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/14-Divide-and-Conquer/app.js b/exercises/14-Divide-and-Conquer/app.js index 97665881..c9ebb4a4 100644 --- a/exercises/14-Divide-and-Conquer/app.js +++ b/exercises/14-Divide-and-Conquer/app.js @@ -1,3 +1,3 @@ -let listOfNumbers = [4, 80, 85, 59, 37, 25, 5, 64, 66, 81, 20, 64, 41, 22, 76, 76, 55, 96, 2, 68]; +let listOfNumbers = [4, 80, 85, 59, 37, 25, 5, 64, 66, 81, 20, 64, 41, 22, 76, 76, 55, 96, 2, 68]; // Your code here From f570c19f29e3b2fa16ec2c0b6fdc089072caee03 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:03:51 +0200 Subject: [PATCH 93/94] Update solution.hide.js --- .../14-Divide-and-Conquer/solution.hide.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/exercises/14-Divide-and-Conquer/solution.hide.js b/exercises/14-Divide-and-Conquer/solution.hide.js index d43e19e4..040ae8cd 100644 --- a/exercises/14-Divide-and-Conquer/solution.hide.js +++ b/exercises/14-Divide-and-Conquer/solution.hide.js @@ -1,13 +1,17 @@ -let list_of_numbers = [4, 80, 85, 59, 37,25, 5, 64, 66, 81,20, 64, 41, 22, 76,76, 55, 96, 2, 68]; +let listOfNumbers = [4, 80, 85, 59, 37, 25, 5, 64, 66, 81, 20, 64, 41, 22, 76, 76, 55, 96, 2, 68]; -// your code here -function mergeTwoList(array){ - let odd = [] - let even = [] +// Your code here +function mergeTwoList(array) { + let odd = []; + let even = []; for (let i = 0; i < array.length; i++) { - array[i] % 2 == 0 ? even.push(array[i]) : odd.push(array[i]) + if (array[i] % 2 === 0) { + even.push(array[i]); + } else { + odd.push(array[i]); + } } - - return odd.concat(even) -} \ No newline at end of file + + return odd.concat(even); +} From 9306d719a5a17825f3196164cac97c1c78bc7771 Mon Sep 17 00:00:00 2001 From: Jose Mora <109150320+josemoracard@users.noreply.github.com> Date: Wed, 6 Sep 2023 23:07:44 +0200 Subject: [PATCH 94/94] Update test.js --- exercises/14-Divide-and-Conquer/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/14-Divide-and-Conquer/test.js b/exercises/14-Divide-and-Conquer/test.js index 26605dfe..8e8e1bb7 100644 --- a/exercises/14-Divide-and-Conquer/test.js +++ b/exercises/14-Divide-and-Conquer/test.js @@ -19,7 +19,7 @@ test('You have to use a "for" loop', () => { const regex = /for\s*/gm expect(regex.test(file.toString())).toBeTruthy(); }) -test('You have to use a "for" loop', () => { +test('You must use the .concat() method', () => { const file = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8'); const regex = /.concat\s*/gm expect(regex.test(file.toString())).toBeTruthy(); @@ -63,4 +63,4 @@ test('The returned array must contain inside all the even items at the end', () _evens_1.forEach((num, i) => expect(num).toEqual(arrTest_1[i + 8])) _evens_2.forEach((num, i) => expect(num).toEqual(arrTest_2[i + 5])) -}); \ No newline at end of file +});