Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
950aaff
up to 3 exercises
UmiKami Jun 17, 2022
49797a5
added spanish instruction
UmiKami Jun 17, 2022
bf3fd98
added new exercise
UmiKami Jun 17, 2022
4c6d1b2
Removed hello-world exexercise and added folder for upcoming exercises
UmiKami Jun 19, 2022
b62eab6
Instructions for all exercises added and fixed
UmiKami Jun 19, 2022
a058a96
added test for exercise 05
UmiKami Jun 19, 2022
7655803
test for exercise 06 done
UmiKami Jun 20, 2022
e3e6327
Finished test for 07
UmiKami Jun 20, 2022
af3ce7c
Test for exercise 08 done
UmiKami Jun 20, 2022
5430413
Test for exercise 09 done
UmiKami Jun 20, 2022
c4c16bb
Test for exercise 10 done
UmiKami Jun 20, 2022
25697f6
All tests checked and working properly.
UmiKami Jun 20, 2022
d5b0d0f
Removed solution from app.js files and added them to solution.hide.js…
UmiKami Jun 20, 2022
9c696ef
Added folder and base files for the last 10 excercises to make a tota…
UmiKami Jun 21, 2022
ac43732
Added tests for 11-15 and fixed respective README
UmiKami Jun 23, 2022
912374a
added exercises 16-20
UmiKami Jun 23, 2022
3fc8081
added test 18 - review please
UmiKami Jun 23, 2022
b8d2d33
Exercises reorganized and fixes applied
UmiKami Jun 27, 2022
53dd569
dockerfile and gitpod.yml file added
tommygonzaleza Jun 27, 2022
409232d
Merge pull request #1 from tommygonzaleza/main
UmiKami Jun 27, 2022
35bce81
learnpack clean ran
tommygonzaleza Jun 27, 2022
3a2fd94
Merge pull request #2 from tommygonzaleza/main
UmiKami Jun 27, 2022
cb3dd7e
Merge branch 'master'
UmiKami Jun 28, 2022
8327b2a
merge
UmiKami Jun 28, 2022
a0d9f2e
updated gitpod btn
UmiKami Jun 28, 2022
ebb9681
Update README.md
tommygonzaleza Jun 30, 2022
733cd1d
Merge pull request #1 from tommygonzaleza/patch-1
UmiKami Jun 30, 2022
7b4ef2c
Update README.es.md
UmiKami Jun 30, 2022
63025ab
Update README.es.md
UmiKami Jun 30, 2022
cc3022b
Update README.es.md
UmiKami Jul 5, 2022
826f988
changed root of learnpack exercises and added owner's original exercises
UmiKami Jul 7, 2022
2db8150
fixed errors in readme
UmiKami Jul 11, 2022
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
Binary file added .DS_Store
Binary file not shown.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# configuration and readme
!.gitignore
!.gitpod.yml
!.gitpod.Dockerfile
!learn.json
!README.md

# exercises
!.learn/
!.learn/*
.learn/_app
.learn/.session
.learn/dist
.learn/app.tar.gz
.learn/config.json

# python compiled files
*.pyc
__pycache__/
.pytest_cache/
7 changes: 7 additions & 0 deletions .gitpod.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gitpod/workspace-full:latest

USER gitpod

RUN npm i jest@24.8.0 -g

RUN npm i @learnpack/learnpack -g && learnpack plugins:install @learnpack/node
19 changes: 19 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
image:
file: .gitpod.dockerfile

ports:
- port: 3000
onOpen: ignore

vscode:
extensions:
- learn-pack.learnpack-vscode

github:
prebuilds:
# enable for the master/default branch (defaults to true)
master: true
# enable for pull requests coming from this repo (defaults to true)
pullRequests: false
# add a "Review in Gitpod" button as a comment to pull requests (defaults to true)
addComment: false
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 700,
"editor.minimap.enabled": false
}
133 changes: 133 additions & 0 deletions README.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Desafíos de codificación JavaScript :computadora:
Este repositorio contiene un conjunto de desafíos de programación JavaScript junto con las soluciones.

**Preguntas de desafío:**
Todos los desafíos se enumeran a continuación.

**Soluciones:**
Los enlaces a las soluciones se proporcionan debajo de las preguntas.

**Abrir desafios con learnpack:**

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/rahni1/javascript-challenges.git)

RETOS:

**1. Validacion de Números:**
Haga que la función ```checkNums(num1,num2)``` tome ambos parámetros que se pasan e imprima verdadero si num2 es mayor que num1, de lo contrario imprima falso.
Si los valores de los parámetros son iguales entre sí, imprima -1.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/CheckNums.js)**

**2. Comparar Strings:**
Cree una función que tome dos strings como argumentos y devuelva true o false
dependiendo de si el número total de caracteres en el primer string es igual a la
número total de caracteres en el segundo string.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/CompareStrings.js)**

**3. Concatenar Arrays:**
Cree una función para concatenar dos arrays de tipo int.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/ConcatenateArrays.js)**

**4. Contar las Vocales:**
Cree una función que tome un string e imprima el número de vocales que contiene.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/VowelCount.js)**

**5. Fecha y Hora:** 📅
- Imprime la fecha y hora actuales en el formato predeterminado.
- Imprime la fecha y hora actual en estilo localizado.
- Imprime la fecha y hora actuales con un patrón.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/DateTime.js)**

**6. Divisible por 5:**
Cree una función que imprima true si un número entero es divisible por 5 y false en caso contrario.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/DivisibleBy5.js)**

**7. Factorial:**
Este desafío requiere que devuelvas el factorial de un número dado. El factorial de un numero
(num), es num multiplicado por (num-1) multiplicado por (num-2) y así sucesivamente hasta llegar al número 1.
Por ejemplo, el factorial de 4 es 4 * 3 * 2 * 1 = 24. Bucle de 1 a num, multiplicando cada número por
el anterior, hasta llegar al número.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/Factorial.js)**

**8. Fibonacci:**
La secuencia de Fibonacci es una secuencia de números cuya suma es los dos números anteriores (por ejemplo, 0, 1, 1, 2, 3, etc.).
Usando 0 y 1 como valores iniciales, cree una función que imprima un array que contenga todos los valores de Fibonacci
hasta el 10000.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/Fibonacci.js)**

**9. FizzBuzz:**
Escriba un programa que imprima los números del 1 al 100. Pero para múltiplos de tres, escriba "Fizz" en lugar de
el número y para los múltiplos de cinco escriba “Buzz”. Para números que son múltiplos de tres y cinco
imprime "FizzBuzz".

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/FizzBuzz.js)**

**10. Letras en Mayúscula:**
Cree una función que convierta el primer carácter de cada palabra en mayúsculas. Imprime el string recién formateado.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/CapitaliseEveryLetter.js)**

**11. Multiplicar y Saltar:**
Imprime los múltiplos de 5 saltando los múltiplos de 3.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/MultiplySkip.js)**

**12.Cambio de Nombre:**
Cambie su apellido usando una función constructora, la función changeName y una instancia de objeto.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/NameChange.js)**

**13. Palíndromo:**
Dado un string de texto, imprime true o false indicando si el texto es o no un palíndromo.
Un palíndromo es una palabra, número u otra secuencia de caracteres que se lee igual hacia atrás que hacia adelante,
como "Ana" o "Otto". También puede crear un palíndromo de números enteros (int).

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/Palindrome.js)**

**14. Eliminar Personajes:**
Elimina el primer y último carácter de un string.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/RemoveChars.js)**

**15. Comparte el Pastel:** 🍰
Cree una función que determine si es posible o no compartir el pastel de manera justa dados estos tres
parámetros:
Partes totales, Destinatarios, Partes cada uno.
Está bien no usar todo el pastel.
Imprima true si el pastel se puede compartir por igual, de lo contrario imprima false.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/SplitCake.js)**

**16. Formatear Número de Teléfono:**
Cree una función que tome un array de 10 números entre 0 y 9 y devuelva un string de números con formato de número de teléfono.
La llamada a la función debería parecerse a algo como esto: ```formatPhoneNumber(4, 4, 1, 2, 3, 4, 5, 6, 7, 8).```

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/FormatPhoneNumber.js)**

**17. Halla el Área de un Triángulo:**
Escribe una función que tome la base y la altura de un triángulo e imprima su área.
**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/AreaOfTriangle.js)**

**18. Palabra Más Larga:**
Escriba una función que tome (sen) como parámetro e imprima la palabra más larga en una oración.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/LongestWord.js)**

**19. Ángulo Faltante:**
Cree una función que clasifique el ángulo faltante como "agudo", "derecho" u "obtuso" según sus grados. Proporcione dos números como argumentos y calcule el grado faltante sumando los dos números y restándolo de 180.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/missingAngle.js)**

**20. Límite de Número:**
Escriba una función que tome tres argumentos numéricos (un número como entrada y los otros dos números que representan los puntos más bajo y más alto del rango). Si el número cae dentro del rango, imprima el número.
Si el número es menor que el límite inferior del rango, imprime el número del límite más bajo y si el número es mayor que el límite superior del rango, imprime el número del límite más alto.

**[Solución](https://github.com/RahniKaurBansal/JS-Challenges/blob/master/limitNumValue.js)**
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ All of the challenges are listed below.
**Solutions:**
The links to the solutions are provided below the questions.

**Open challenges with learnpack:**

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/rahni1/javascript-challenges.git)

CHALLENGES:

**1. Check Nums:**
Expand Down
7 changes: 7 additions & 0 deletions exercises/01-CheckNums/README.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `01` Check Nums

Haz que la funcion checkNums(num1,num2) tome lo dos parametros siendo pasados.

## Instrucciones 🗒
1. Retorna `true` si `num2` es mayor que `num1`, de lo contrario retorna `false`.
2. Si los paremetros son iguales retorna `-1`.
7 changes: 7 additions & 0 deletions exercises/01-CheckNums/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `01` Check Nums

Have the function checkNums(num1,num2) take both parameters being passed.

## Instructions 🗒
1. Return true if `num2` is greater than `num1`, otherwise return `false`.
2. If the parameter values are equal to each other then return `-1`.
1 change: 1 addition & 0 deletions exercises/01-CheckNums/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// your code here
4 changes: 4 additions & 0 deletions exercises/01-CheckNums/solution.hide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// your code here
function checkNums(num1, num2) {
return num2 > num1 ? true : num1 > num2 ? false : -1;
}
22 changes: 22 additions & 0 deletions exercises/01-CheckNums/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const rewire = require("rewire");
const app = rewire("./app.js");

test('There should be a checkNums function', () => {
const checkNums = app.__get__("checkNums");
expect(checkNums).toBeTruthy();
})

test('If num2 is bigger than num1 you should return true', () => {
const checkNums = app.__get__("checkNums");
expect(checkNums(4, 23)).toBe(true);
});

test("If num2 is less than num1 you should return false", () => {
const checkNums = app.__get__("checkNums");
expect(checkNums(23, 4)).toBe(false);
});

test("If num1 is EQUAL to num2 you should return -1", () => {
const checkNums = app.__get__("checkNums");
expect(checkNums(5, 5)).toBe(-1);
});
6 changes: 6 additions & 0 deletions exercises/02-CompareStrings/README.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# `02` Compare Strings

Crea una funcion `compareStrings` que toma dos strings como argumentos.

## Instrucciones 🗒
1. Retorna `true` o `false` dependiendo en que el total de caracteres en la primera string sea igual en tamanio al numero de caracters en la segunda string.
6 changes: 6 additions & 0 deletions exercises/02-CompareStrings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# `02` Compare Strings

Create a function `compareStrings` that takes two strings as arguments.

## Instructions 🗒
1. Return either `true` or `false` depending on whether the total number of characters in the first string is equal to the total number of characters in the second string.
1 change: 1 addition & 0 deletions exercises/02-CompareStrings/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// your code here
8 changes: 8 additions & 0 deletions exercises/02-CompareStrings/solution.hide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// your code here
function compareStrings(string1, string2) {
if (string1.length === string2.length) {
return true;
} else {
return false;
}
}
15 changes: 15 additions & 0 deletions exercises/02-CompareStrings/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const rewire = require("rewire")
const app = rewire("./app.js")

test('Function compareStrings should exist', ()=>{
const compareStrings = app.__get__("compareStrings")
expect(compareStrings).toBeTruthy();
});
test('If the strings have the same length it should be true', ()=>{
const compareStrings = app.__get__("compareStrings")
expect(compareStrings("hello", "table")).toBe(true);
});
test('If the strings have the different lengths it should be false', ()=>{
const compareStrings = app.__get__("compareStrings")
expect(compareStrings("zoo", "spectacular")).toBe(false);
});
5 changes: 5 additions & 0 deletions exercises/03-ConcatenateArrays/README.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `03` Concatenate Arrays

## Instrucciones 🗒
1. Crea una funcion `concatenateIntArrays` que una dos `integer` arrays.
2. La funcion debe tomar `dos` arrays como argumento y retornar un `solo` array.
5 changes: 5 additions & 0 deletions exercises/03-ConcatenateArrays/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `03` Concatenate Arrays

## Instructions 🗒
1. Create a function `concatenateIntArrays` to concatenate two `integer` arrays.
2. The function should take `two` arrays as arguments and return a `single` array.
1 change: 1 addition & 0 deletions exercises/03-ConcatenateArrays/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// your code here
4 changes: 4 additions & 0 deletions exercises/03-ConcatenateArrays/solution.hide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function concatenateIntArrays(array1, array2) {
const result = array1.concat(array2);
return result;
}
14 changes: 14 additions & 0 deletions exercises/03-ConcatenateArrays/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const rewire = require("rewire");
const app = rewire("./app.js");

test("concatenateIntArrays function must exist.", () => {
const concatenateIntArrays = app.__get__("concatenateIntArrays");
expect(concatenateIntArrays).toBeTruthy();
});

test("The final output should be a mix of the two arrays", () => {
const concatenateIntArrays = app.__get__("concatenateIntArrays");

expect(concatenateIntArrays([2, 3, 4, 6], [7, 12, 32, 64])).toEqual([2, 3, 4, 6, 7, 12, 32, 64]);
expect(concatenateIntArrays([1, 2, 3, 4, 5], [6, 7, 8, 9, 10])).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
});
4 changes: 4 additions & 0 deletions exercises/04-VowelCount/README.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# `04` Vowel Counter

## Instructions 🗒
1. Crea una funcion que tome un `string` y retorne la cantidad de vocales que esta contiene.
4 changes: 4 additions & 0 deletions exercises/04-VowelCount/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# `04` Vowel Counter

## Instructions 🗒
1. Create a function that takes a `string` and returns the number of vowels contained within it.
1 change: 1 addition & 0 deletions exercises/04-VowelCount/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// your code here
5 changes: 5 additions & 0 deletions exercises/04-VowelCount/solution.hide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// your code here
function findVowels(word) {
const matched = word.match(/[aeiou]/gi);
return matched ? matched.length : 0;
}
15 changes: 15 additions & 0 deletions exercises/04-VowelCount/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const rewire = require("rewire")
const app = rewire('./app.js')


test('findVowels function must exist.', ()=>{
const findVowels = app.__get__('findVowels')
expect(findVowels).toBeTruthy();
})

test('You must have the correct number of vowels', ()=>{
const findVowels = app.__get__("findVowels");

expect(findVowels("carola")).toBe(3)
expect(findVowels("youtube")).toBe(4)
})
6 changes: 6 additions & 0 deletions exercises/05-DateTime/README.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# `05` Date and Time

## Instrucciones 🗒
1. Imprima la fecha y la hora actuales en el formato predeterminado. Asigne el resultado final a una variable `today`.
2. Imprima la fecha y hora actual en estilo localizado. Asigne el resultado final a unas variables `date` y `time`.
3. Imprima la fecha y hora actuales con un patrón. Asigne el resultado final a una variable `dateTime`.
7 changes: 7 additions & 0 deletions exercises/05-DateTime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `05` Date and Time

## Instructions 🗒
1. Print the current date and time in default format. Assign the final result to a `today` variable.
2. Print the current date and time in localised style. Assign the final result to a `date` and `time` variabales.
3. Print the current date and time with a pattern. Assign the final result to a `dateTime` variable.

1 change: 1 addition & 0 deletions exercises/05-DateTime/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// your code here
Loading