From 11757efb6ee6c8730a267890d860b4840c4c086c Mon Sep 17 00:00:00 2001 From: bhanuvikram <5193270+bhanuvikram@users.noreply.github.com> Date: Sun, 17 Mar 2024 13:07:11 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20updated=20URL=20to=20get=20high=20qualit?= =?UTF-8?q?y=20Pok=C3=A9mon=20images?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pokedex/script.js | 84 +++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/pokedex/script.js b/pokedex/script.js index 6b824d9..461d6b9 100644 --- a/pokedex/script.js +++ b/pokedex/script.js @@ -1,64 +1,64 @@ -const poke_container = document.getElementById('poke-container') -const pokemon_count = 150 +const poke_container = document.getElementById("poke-container"); +const pokemon_count = 150; const colors = { - fire: '#FDDFDF', - grass: '#DEFDE0', - electric: '#FCF7DE', - water: '#DEF3FD', - ground: '#f4e7da', - rock: '#d5d5d4', - fairy: '#fceaff', - poison: '#98d7a5', - bug: '#f8d5a3', - dragon: '#97b3e6', - psychic: '#eaeda1', - flying: '#F5F5F5', - fighting: '#E6E0D4', - normal: '#F5F5F5' -} + fire: "#FDDFDF", + grass: "#DEFDE0", + electric: "#FCF7DE", + water: "#DEF3FD", + ground: "#f4e7da", + rock: "#d5d5d4", + fairy: "#fceaff", + poison: "#98d7a5", + bug: "#f8d5a3", + dragon: "#97b3e6", + psychic: "#eaeda1", + flying: "#F5F5F5", + fighting: "#E6E0D4", + normal: "#F5F5F5", +}; -const main_types = Object.keys(colors) +const main_types = Object.keys(colors); const fetchPokemons = async () => { - for(let i = 1; i <= pokemon_count; i++) { - await getPokemon(i) - } -} + for (let i = 1; i <= pokemon_count; i++) { + await getPokemon(i); + } +}; const getPokemon = async (id) => { - const url = `https://pokeapi.co/api/v2/pokemon/${id}` - const res = await fetch(url) - const data = await res.json() - createPokemonCard(data) -} + const url = `https://pokeapi.co/api/v2/pokemon/${id}`; + const res = await fetch(url); + const data = await res.json(); + createPokemonCard(data); +}; const createPokemonCard = (pokemon) => { - const pokemonEl = document.createElement('div') - pokemonEl.classList.add('pokemon') + const pokemonEl = document.createElement("div"); + pokemonEl.classList.add("pokemon"); - const name = pokemon.name[0].toUpperCase() + pokemon.name.slice(1) - const id = pokemon.id.toString().padStart(3, '0') + const name = pokemon.name[0].toUpperCase() + pokemon.name.slice(1); + const id = pokemon.id.toString().padStart(3, "0"); - const poke_types = pokemon.types.map(type => type.type.name) - const type = main_types.find(type => poke_types.indexOf(type) > -1) - const color = colors[type] + const poke_types = pokemon.types.map((type) => type.type.name); + const type = main_types.find((type) => poke_types.indexOf(type) > -1); + const color = colors[type]; - pokemonEl.style.backgroundColor = color + pokemonEl.style.backgroundColor = color; - const pokemonInnerHTML = ` + const pokemonInnerHTML = `