-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from josemoracard/jose4-07.2-letter-counter
exercises 07.2-letter-counter to 14-divide-and-conquer
- Loading branch information
Showing
53 changed files
with
285 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
console.log(counts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
console.log(counts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
+ 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()`? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
let arr = [45,67,87,23,5,32,60]; | ||
|
||
//Your code here. | ||
// Your code here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
console.log(flippedArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
let mix = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}]; | ||
|
||
//your code here | ||
// Your code here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|
||
console.log(newArray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.