Build a Pokémon Search App Project - Build a Pokémon Search App

Tell us what’s happening:

Hi Community! I am working on my last project . I would really appreciate your help/insight. I keep throwing the errors

  1. When the #search-input element contains the value Pikachu and the #search-button element is clicked, the values in the #pokemon-name, #pokemon-id, #weight, #height, #hp, #attack, #defense, #special-attack, #special-defense, and #speed elements should be PIKACHU, #25 or 25, Weight: 60 or 60, Height: 4 or 4, 35, 55, 40, 50, 50, and 90, respectiv.

&& #18 which is the same

Your code so far

const searchInput = document.getElementById("search-input");
const searchButton = document.getElementById("search-button");
const pokemonName = document.getElementById("pokemon-name");
const pokemonId = document.getElementById("pokemon-id");
const pokemonImage = document.getElementById("pokemon-image");
const pokemonWeight = document.getElementById("weight");
const pokemonHeight = document.getElementById("height");
const pokemonTypes = document.getElementById("types");
const hp = document.getElementById("hp");
const attack = document.getElementById("attack");
const defense = document.getElementById("defense");
const specialAttack = document.getElementById("special-attack");
const specialDefense = document.getElementById("special-defense");
const speed = document.getElementById("speed");


const searchPokedex = async () => {
try{
  const res = await fetch(`https://pokeapi-proxy.freecodecamp.rocks/api/pokemon/${searchInput.value.toLowerCase()}`);
  const data = await res.json();

  const { name, weight, height, id, stats, sprites, types } = data;

  pokemonName.innerHTML = name.toUpperCase();
  pokemonId.innerHTML = id
  pokemonWeight.innerHTML = `Weight:${weight}`;
  pokemonHeight.innerHTML = `Height:${height}`;

  pokemonImage.innerHTML = `<img id="sprite" src="${sprites.front_default}">`
  pokemonTypes.innerHTML = types.map(type => `<span>${type.type.name.toUpperCase()}</span>`).join("");


    hp.textContent = data.stats[0].base_stat;
    attack.textContent = data.stats[1].base_stat;
    defense.textContent = data.stats[2].base_stat;
    specialAttack.textContent = data.stats[3].base_stat;
    specialDefense.textContent = data.stats[4].base_stat;
    speed.textContent = data.stats[5].base_stat;
    

/*Stats
  hp.innerHTML = stats[0].base_stat;
  attack.innerHTML = stats[1].base_stat;
  defense.innerHTML = stats[2].base_stat;
  specialAttack.innerHTML = stats[3].base_stat;
  specialDefense.innerHTML = stats[4].base_stat;
  speed.innerHTML = stats[5].base_stat;
*/


  console.log(data);
  } catch(err){
    alert("Pokemon not found");
    console.log(err.message)
  }
}

searchButton.addEventListener("click", searchPokedex);

searchInput.addEventListener("keydown", (e) => {
  if(e.key === "Enter"){
    searchPokedex()
  }
})

/*
15. When the #search-input element contains the value Pikachu and the #search-button element is clicked, the values in the #pokemon-name, #pokemon-id, #weight, #height, #hp, #attack, #defense, #special-attack, #special-defense, and #speed elements should be PIKACHU, #25 or 25, Weight: 60 or 60, Height: 4 or 4, 35, 55, 40, 50, 50, and 90, respectively.

  1. When the #search-input element contains the value 94 and the #search-button element is clicked, the values in the #pokemon-name, #pokemon-id, #weight, #height, #hp, #attack, #defense, #special-attack, #special-defense, and #speed elements should be GENGAR, #94 or 94, Weight: 405 or 405, Height: 15 or 15, 60, 65, 60, 130, 75, and 110, respectively.

*/

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36

Challenge Information:

Build a Pokémon Search App Project - Build a Pokémon Search App

I actually solved it! it was a syntactical error. Thank you !

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').