Skip to content

Commit 4d93c32

Browse files
authored
Merge pull request mouredev#6991 from 7R0N1X/main
#20 - JavaScript
2 parents f730703 + 78a01fe commit 4d93c32

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const peticion = async () => {
2+
const response = await fetch('https://tronix-portfolio.vercel.app')
3+
if (response.ok) {
4+
const data = await response.text()
5+
console.log(data)
6+
}
7+
}
8+
9+
// peticion()
10+
11+
// DIFICULTAD EXTRA
12+
const obtenerInfoPokemon = async (pokemon) => {
13+
const response = await fetch(`https://pokeapi.co/api/v2/pokemon/${pokemon}`)
14+
if (response.ok) {
15+
const { id, forms: [{ name }], weight, height, types, game_indices } = await response.json()
16+
return {
17+
id, name, height, weight, types, game_indices
18+
}
19+
}
20+
}
21+
22+
const mostrarInformacion = async (pokemon) => {
23+
const response = await obtenerInfoPokemon(pokemon)
24+
const { id, name, weight, height, types, game_indices } = response
25+
const tipos = types.map(type => type.type.name)
26+
const juegos = game_indices.map(juego => juego.version.name)
27+
28+
console.log(`
29+
ID: ${id}
30+
Nombre: ${name}
31+
Altura: ${height}
32+
Peso: ${weight}
33+
Tipo(s): ${tipos}
34+
Juegos: ${juegos}
35+
`)
36+
}
37+
38+
mostrarInformacion(1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const procesarNombres = (nombres, callback) => {
2+
nombres.forEach(nombre => {
3+
console.log(nombre.toUpperCase())
4+
});
5+
callback()
6+
}
7+
8+
const mostrarMensajeFinal = () => {
9+
console.log('Procesamiento terminado.')
10+
}
11+
12+
const nombres = ['7r0n1x', 'eduardo', 'ana', 'pedro']
13+
procesarNombres(nombres, mostrarMensajeFinal)
14+
15+
// DIFICULTAD EXTRA
16+
17+
const procesarPedidos = (nombreDelPlato, cbConfirmacion, cbListo, cbEntrega) => {
18+
setTimeout(() => {
19+
cbConfirmacion(nombreDelPlato)
20+
setTimeout(() => {
21+
cbListo(nombreDelPlato)
22+
setTimeout(() => {
23+
cbEntrega(nombreDelPlato)
24+
}, Math.floor((Math.random() * (10 - 1 + 1)) + 1) * 1000)
25+
}, Math.floor((Math.random() * (10 - 1 + 1)) + 1) * 1000)
26+
}, Math.floor((Math.random() * (10 - 1 + 1)) + 1) * 1000)
27+
}
28+
29+
const confirmacion = (nombreDelPlato) => {
30+
console.log(`El pedido de ${nombreDelPlato} a sido confirmado.`)
31+
}
32+
33+
const listo = (nombreDelPlato) => {
34+
console.log(`El pedido de ${nombreDelPlato} está listo.`)
35+
}
36+
37+
const entraga = (nombreDelPlato) => {
38+
console.log(`El pedido de ${nombreDelPlato} a sido entregado.`)
39+
}
40+
41+
procesarPedidos('Ceviche', confirmacion, listo, entraga)

0 commit comments

Comments
 (0)