Skip to content

ejercicios cambios varios #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
c056990
Update README.es.md
josemoracard Jul 11, 2023
8895e40
Update solution.hide.js
josemoracard Jul 11, 2023
cafc0df
Update test.js
josemoracard Jul 11, 2023
13a6515
Update solution.hide.js
josemoracard Jul 11, 2023
94965b5
Update README.es.md
josemoracard Jul 11, 2023
a99d837
Update README.md
josemoracard Jul 11, 2023
fa0e0fe
Update README.md
josemoracard Jul 11, 2023
8106c3f
Update README.es.md
josemoracard Jul 11, 2023
e036242
Update README.es.md
josemoracard Jul 11, 2023
485cc28
Update README.md
josemoracard Jul 11, 2023
a5027ce
Update README.es.md
josemoracard Jul 11, 2023
9c5803d
Update solution.hide.js
josemoracard Jul 11, 2023
d24fa2c
Update app.js
josemoracard Jul 11, 2023
7599dca
Update README.md
josemoracard Jul 11, 2023
41e3dcd
Update README.es.md
josemoracard Jul 11, 2023
48b0503
Update solution.hide.js
josemoracard Jul 11, 2023
1f3bc85
Update test.js
josemoracard Jul 11, 2023
dac29b4
Update test.js
josemoracard Jul 11, 2023
2bf6221
Update README.es.md
josemoracard Jul 11, 2023
bad6c67
Update solution.hide.js
josemoracard Jul 11, 2023
f6e5261
Update solution.hide.js
josemoracard Jul 11, 2023
b40e723
Update solution.hide.js
josemoracard Jul 11, 2023
cbf3707
Update solution.hide.js
josemoracard Jul 11, 2023
3e34d18
Update solution.hide.js
josemoracard Jul 11, 2023
5fc6a72
Update test.js
josemoracard Jul 11, 2023
ae75a3e
Update README.es.md
josemoracard Jul 12, 2023
7f51e34
Update README.md
josemoracard Jul 12, 2023
17c3126
Update README.md
josemoracard Jul 12, 2023
b386afc
Update README.es.md
josemoracard Jul 12, 2023
473aa82
Update README.md
josemoracard Jul 12, 2023
e5202e5
Update README.es.md
josemoracard Jul 12, 2023
b3a6e4d
Update README.md
josemoracard Jul 12, 2023
ce6b9b3
Update README.es.md
josemoracard Jul 12, 2023
c127482
Update app.js
josemoracard Jul 12, 2023
c37e9bf
Update app.js
josemoracard Jul 12, 2023
bd6a4a4
Update README.md
josemoracard Jul 12, 2023
937c9a2
Update README.es.md
josemoracard Jul 12, 2023
8b548dd
Update README.md
josemoracard Jul 12, 2023
016a692
Update solution.hide.js
josemoracard Jul 12, 2023
2f1d630
Update app.js
josemoracard Jul 12, 2023
88f5b44
Update app.js
josemoracard Jul 12, 2023
27f64bf
Update solution.hide.js
josemoracard Jul 12, 2023
c585727
Update app.js
josemoracard Jul 12, 2023
c46b500
Update solution.hide.js
josemoracard Jul 12, 2023
c905351
Update solution.hide.js
josemoracard Jul 12, 2023
24cfbc0
Update README.md
josemoracard Jul 12, 2023
331ac85
Update README.es.md
josemoracard Jul 12, 2023
63bebeb
Update README.md
josemoracard Jul 12, 2023
f57c275
Update solution.hide.js
josemoracard Jul 12, 2023
e9a92c9
Update test.js
josemoracard Jul 12, 2023
dd22112
Update README.md
josemoracard Jul 12, 2023
a67fba1
Update README.es.md
josemoracard Jul 12, 2023
7e4fb50
Update README.md
josemoracard Jul 12, 2023
39e880e
Update README.es.md
josemoracard Jul 12, 2023
31dd670
Update README.md
josemoracard Jul 12, 2023
29aa451
Update README.es.md
josemoracard Jul 12, 2023
51513f3
Update README.md
josemoracard Jul 12, 2023
f606be5
Update README.es.md
josemoracard Jul 12, 2023
44731d7
Update README.md
josemoracard Jul 12, 2023
e426560
Update README.es.md
josemoracard Jul 12, 2023
1e10416
Update README.md
josemoracard Jul 12, 2023
6dc4a7c
Update README.es.md
josemoracard Jul 12, 2023
6927a96
Update solution.hide.js
josemoracard Jul 12, 2023
efbb1f4
Update solution.hide.js
tommygonzaleza Jul 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion exercises/065-or/README.es.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# `065` or

En este ejercicio vamos a replicar el comportamiento del operador lógico OR `||` sin usar el propio operador. ¿Recuerdas cómo funciona?

## 📝 Instrucciones:

1. Escribe una función llamada `or`. Dadas 2 expresiones booleanas, `or` retorna true o false, correspondiente al operador `||`.
1. Escribe una función llamada `or`. Dadas 2 expresiones booleanas, `or` retorna true o false, siguiendo las reglas del operador `||`.

## 📎 Ejemplo:

Expand Down
4 changes: 3 additions & 1 deletion exercises/065-or/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# `065` or

In this exercise, we are going to replicate the behavior of the logical operator OR `||` without actually using the operator itself. Do you remember how it works?

## 📝 Instructions:

1. Write a function called `or`. Given 2 boolean expressions, `or` returns true or false, corresponding to the `||` operator.
1. Write a function called `or`. Given 2 boolean expressions, `or` returns true or false, following the rules of the `||` operator.

## 📎 Example:

Expand Down
16 changes: 9 additions & 7 deletions exercises/107-getLengthOfLongestElement/solution.hide.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
function getLengthOfLongestElement(arr) {
// Your code here
if (arr.length < 1) return 0
else {
let aux = 0
arr.map(item=> item.length > aux ? aux = item.length : null)
return aux;
// your code here
let longestLength = 0;
for (let i = 0; i < arr.length; i++) {
if (arr[i].length > longestLength) {
longestLength = arr[i].length;
}
}

return longestLength;
}

let output = getLengthOfLongestElement(['one', 'two', 'three']);
console.log(output); // --> 5
console.log(output); // --> 5
2 changes: 1 addition & 1 deletion exercises/111-getElementOfArrayProperty/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 📝 Instrucciones:

1. Escribe una función llamada `getElementOfArrayProperty`. Dados un objeto, una key y un index númerico, `getElementOfArrayProperty` retorna el valor de un elemento en el index proporcionado del array ubicado dentro del objeto en la key dada.
1. Escribe una función llamada `getElementOfArrayProperty`. Dados un objeto, una key y un index numérico, `getElementOfArrayProperty` retorna el valor de un elemento en el index proporcionado del array ubicado dentro del objeto en la key dada.

## 📎 Ejemplo:

Expand Down
2 changes: 1 addition & 1 deletion exercises/120-getLargestElement/solution.hide.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function getLargestElement(arr) {
// your code here
if (arr.length < 1) return 0;

let aux = 0;
let aux = arr[0];
for (let e of arr) {
if (aux < e) aux = e;
}
Expand Down
4 changes: 4 additions & 0 deletions exercises/120-getLargestElement/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ test('Function must return the largest number within the array. Testing with dif
expect(getLargestElement([15, 22, 18, 23])).toBe(23);
});

test('Function must return the largest number within the array. Testing with different values', () => {
expect(getLargestElement([-5, -2, -8, -3])).toBe(-2);
});

test('If array is empty, it should return 0', () => {
let output = getLargestElement([]);
expect(output).toBe(0);
Expand Down
2 changes: 1 addition & 1 deletion exercises/121-computeSumOfAllElements/solution.hide.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ function computeSumOfAllElements(arr) {
return aux;
}

var output = computeSumOfAllElements([1, 2, 3]);
let output = computeSumOfAllElements([1, 2, 3]);
console.log(output); // --> 6
2 changes: 1 addition & 1 deletion exercises/124-joinArraysOfArrays/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## 📝 Instrucciones:

1. Escribe una función llamada `joinArrayOfArrays`. Dado una matriz (array de arrays), `joinArrayOfArrays` retorna un array único que contenga los elementos de los arrays anidados.
1. Escribe una función llamada `joinArrayOfArrays`. Dada una matriz (array de arrays), `joinArrayOfArrays` retorna un array único que contenga los elementos de los arrays anidados.

## 📎 Ejemplo:

Expand Down
16 changes: 7 additions & 9 deletions exercises/133-convertScoreToGrade/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ console.log(output); // --> 'A'

## 💡 Pistas:

+ (100 - 90) --> 'A'

+ (89 - 80) --> 'B'

+ (79 - 70) --> 'C'

+ (69 - 60) --> 'D'

+ (59 - 0) --> 'F'
| Puntaje | Grado |
|:---------:|:-------:|
| 100 - 90 | 'A' |
| 89 - 80 | 'B' |
| 79 - 70 | 'C' |
| 69 - 60 | 'D' |
| 59 - 0 | 'F' |

+ Si la puntuación dada es mayor que 100 o menor que 0, `convertScoreToGrade` debería retornar `INVALID SCORE`.
16 changes: 7 additions & 9 deletions exercises/133-convertScoreToGrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ console.log(output); // --> 'A'

## 💡 Hints:

+ (100 - 90) --> 'A'

+ (89 - 80) --> 'B'

+ (79 - 70) --> 'C'

+ (69 - 60) --> 'D'

+ (59 - 0) --> 'F'
| Score | Grade |
|:---------:|:-------:|
| 100 - 90 | 'A' |
| 89 - 80 | 'B' |
| 79 - 70 | 'C' |
| 69 - 60 | 'D' |
| 59 - 0 | 'F' |

+ If the given score is greater than 100 or less than 0, `convertScoreToGrade` should return `INVALID SCORE`.
16 changes: 7 additions & 9 deletions exercises/134-convertScoreToGradeWithPlus/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ console.log(output); // --> 'A-'

## 💡 Pistas:

+ (100 - 90) --> 'A'

+ (89 - 80) --> 'B'

+ (79 - 70) --> 'C'

+ (69 - 60) --> 'D'

+ (59 - 0) --> 'F'
| Puntaje | Grado |
|:---------:|:-------:|
| 100 - 90 | 'A' |
| 89 - 80 | 'B' |
| 79 - 70 | 'C' |
| 69 - 60 | 'D' |
| 59 - 0 | 'F' |

+ Si el puntaje dado es mayor que 100 o menor que 0, debería retornar `INVALID SCORE`.

Expand Down
16 changes: 7 additions & 9 deletions exercises/134-convertScoreToGradeWithPlus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ console.log(output); // --> 'A-'

## 💡 Hints:

+ (100 - 90) --> 'A'

+ (89 - 80) --> 'B'

+ (79 - 70) --> 'C'

+ (69 - 60) --> 'D'

+ (59 - 0) --> 'F'
| Score | Grade |
|:--------: |:-----: |
| 100 - 90 | 'A' |
| 89 - 80 | 'B' |
| 79 - 70 | 'C' |
| 69 - 60 | 'D' |
| 59 - 0 | 'F' |

+ If the given score is greater than 100 or less than 0, it should return `INVALID SCORE`.

Expand Down
4 changes: 2 additions & 2 deletions exercises/135-computeFactorialOfN/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ function computeFactorialOfN(n) {

}

let output = computeFactorialOfN(3);
console.log(output); // --> 6
let output = computeFactorialOfN(4);
console.log(output); // --> 24
3 changes: 0 additions & 3 deletions exercises/135-computeFactorialOfN/solution.hide.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ function computeFactorialOfN(n) {
return aux;
}

let output = computeFactorialOfN(3);
console.log(output); // --> 6

let output = computeFactorialOfN(4);
console.log(output); // --> 24
2 changes: 1 addition & 1 deletion exercises/139-computeCompoundInterest/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ console.log(output); // --> 438.83682213410543

## 💡 Pista:

- Aquí puedes ver la fórmula utilizada para calcular el interés compuesto total generado: [Calculation_of_compound_interest](https://en.wikipedia.org/wiki/Compound_interest#Calculation_of_compound_interest)
- Aquí puedes ver la fórmula utilizada para calcular el interés compuesto total generado: [Calculation_of_compound_interest](https://en.wikipedia.org/wiki/Compound_interest#Calculation)
4 changes: 2 additions & 2 deletions exercises/139-computeCompoundInterest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ let output = computeCompoundInterest(1500, .043, 4, 6);
console.log(output); // --> 438.83682213410543
```

## 💡 Hints:
## 💡 Hint:

- Check the formula used to calculate the total compound insterest generated: [Calculation_of_compound_interest](https://en.wikipedia.org/wiki/Compound_interest#Calculation_of_compound_interest)
- Check the formula used to calculate the total compound insterest generated: [Calculation_of_compound_interest](https://en.wikipedia.org/wiki/Compound_interest#Calculation)
2 changes: 1 addition & 1 deletion exercises/140-modulo/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ console.log(output); // --> 1

## 💡 Pistas:

+ La función debe comportarse como se describe en la [documentación canónica (MDN) para el operador resto de JavaScript](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Operators/Remainder)
+ La función debe comportarse como se describe en la [documentación canónica (MDN) para el operador resto de JavaScript](https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Operators/Remainder).

+ NO uses el operador de módulo incorporado (también conocido como "resto") (`%`) en la implementación.

Expand Down
4 changes: 4 additions & 0 deletions exercises/140-modulo/solution.hide.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
function modulo(num1, num2) {
// your code here
if (num2 === 0 || isNaN(num1) || isNaN(num2)) {
return NaN;
}

let i = 0;
if(num1 > 0) {
while (i < num1) {
Expand Down
28 changes: 22 additions & 6 deletions exercises/141-multiply/solution.hide.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
function multiply(num1, num2) {
// your code here
let aux = 0;
if (num1 < 0) {
for (let times = 0; times < num2; times++) aux += num1;
} else {
for (let times = 0; times < num1; times++) aux += num2;
let result = 0;
let isNegative = false;

// Check if the result will be negative
if ((num1 < 0 && num2 > 0) || (num1 > 0 && num2 < 0)) {
isNegative = true;
}

// Convert both numbers to positive
num1 = Math.abs(num1);
num2 = Math.abs(num2);

// Add num1 to result num2 times
for (let i = 0; i < num2; i++) {
result += num1;
}
return aux;

// If the result should be negative, negate it
if (isNegative) {
result = -result;
}

return result;
}

let output = multiply(2, -7);
Expand Down
12 changes: 10 additions & 2 deletions exercises/141-multiply/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ test('Function multiply must return a number', () => {
expect(typeof multiply(1, 2)).toBe('number');
});

test('Given 2 whole numbers, multiply and return the total', () => {
test('Given 2 integer numbers, multiply and return the total', () => {
expect(multiply(4, 7)).toBe(28);
});

test('Given 2 whole numbers, multiply and return the total. Testing with negative value', () => {
test('Given 2 integer numbers, multiply and return the total. Testing with different values', () => {
expect(multiply(5, -5)).toBe(-25);
});

test('Given 2 integer numbers, multiply and return the total. Testing with different values', () => {
expect(multiply(-5, -3)).toBe(15);
});

test('Given 2 integer numbers, multiply and return the total. Testing with different values', () => {
expect(multiply(0, -5)).toBe(0);
});

test('Must not use the * operator', () => {
let multiplyOperator = '*';
expect(multiplyOperator).not.toBe(multiply);
Expand Down
2 changes: 1 addition & 1 deletion exercises/142-isOddWithoutModulo/solution.hide.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function isOddWithoutModulo(num) {
// your code here
let aux = true;
if(num >= 0){
if (num >= 0) {
for (let x = 0; x <= num + 1; x += 2) {
if (x === num) aux = false;
}
Expand Down
4 changes: 2 additions & 2 deletions exercises/143-isEvenWithoutModulo/solution.hide.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ function isEvenWithoutModulo(num) {
return aux;
}

let output = isEvenWithoutModulo(18);
console.log(output); // --> false
let output = isEvenWithoutModulo(8);
console.log(output); // --> true
2 changes: 1 addition & 1 deletion exercises/143-isEvenWithoutModulo/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('Function isEvenWithoutModulo must exist', () => {
expect(isEvenWithoutModulo).not.toBe(undefined);
});

test('Function isEvenWithoutModulo must exist', () => {
test('Function isEvenWithoutModulo must return something', () => {
expect(isEvenWithoutModulo(1)).not.toBe(undefined);
});

Expand Down
8 changes: 4 additions & 4 deletions exercises/146.1-ArrayToObject/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

## 📝 Instrucciones:

1. Escribe una función `transformFirstAndLast` que tome un array y devuelva un objeto cuyo *primer elemento sea la key del objeto*, y cuyo *último elemento sea el valor de esa key*.
1. Escribe una función `transformFirstAndLast` que tome un array y devuelva un objeto cuyo **primer elemento sea la key del objeto**, y cuyo **último elemento sea el valor de esa key**.

## 📎 Ejemplo 1:

```js
let output = transformFirstAndLast(['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce'])
console.log(output); // { Queen: "Beyonce" }
console.log(output); // --> { Queen: "Beyonce" }
```

## 📎 Ejemplo 2:

```js
let output = transformFirstAndLast(['Kevin', 'Bacon', 'Love', 'Hart', 'Costner', 'Spacey'])
console.log(output); // { Kevin: "Spacey" }
console.log(output); // --> { Kevin: "Spacey" }
```

## 💡 Pistas:
Expand All @@ -24,4 +24,4 @@ console.log(output); // { Kevin: "Spacey" }

+ Asume que todos los elementos en el array de entrada serán del tipo `string`.

+ Ten en cuenta que el array de entrada puede teneruna cantidad variable de elementos por lo que tu código debe ser flexible.
+ Ten en cuenta que el array de entrada puede tener una cantidad variable de elementos por lo que tu código debe ser flexible.
6 changes: 3 additions & 3 deletions exercises/146.1-ArrayToObject/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

## 📝 Instructions:

1. Write a function called `transformFirstAndLast` that takes in an array, and returns an object with *the first element of the array as the object's key*, and *the last element of the array as that key's value*.
1. Write a function called `transformFirstAndLast` that takes in an array, and returns an object with **the first element of the array as the object's key**, and **the last element of the array as that key's value**.

## 📎 Example 1:

```js
let output = transformFirstAndLast(['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce'])
console.log(output); // { Queen: "Beyonce" }
console.log(output); // --> { Queen: "Beyonce" }
```

## 📎 Example 2:

```js
let output = transformFirstAndLast(['Kevin', 'Bacon', 'Love', 'Hart', 'Costner', 'Spacey'])
console.log(output); // { Kevin: "Spacey" }
console.log(output); // --> { Kevin: "Spacey" }
```

## 💡 Hints:
Expand Down
4 changes: 2 additions & 2 deletions exercises/146.2-ArrayToObject/README.es.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# `146.2` ArraytoObject
# `146.2` ArrayToObject

## 📝 Instrucciones:

1. Escribe una función `fromListToObject` que tome una matriz (array de arrays), y retorne *un objeto con cada par de elementos de la matriz como un par clave-valor (key-value)*.
1. Escribe una función `fromListToObject` que tome una matriz (array de arrays), y retorne **un objeto con cada par de elementos de la matriz como un par clave-valor (key-value)**.

## 📎 Ejemplo:

Expand Down
4 changes: 2 additions & 2 deletions exercises/146.2-ArrayToObject/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# `146.2` ArraytoObject
# `146.2` ArrayToObject

## 📝 Instructions:

1. Write a function `fromListToObject` which takes in a matrix (an array of arrays), and returns an object with *each pair of elements in the array as a key-value pair*.
1. Write a function `fromListToObject` which takes in a matrix (an array of arrays), and returns an object with **each pair of elements in the array as a key-value pair**.

## 📎 Example:

Expand Down
Loading