Build a Pokémon Search App Project - Build a Pokémon Search App (is website broken?)

Tell us what’s happening:

When I click “Run the Tests” I always get not pass tests, even I get error that I not have ‘input’ element with an ‘id’

Your code so far

<!-- file: index.html -->
<html lang='en'>
    <head>
        <link rel='stylesheet' href='styles.css'/>
          </head>
            <body>
                <label for='search-input'>Pokomon: </label><input id='search-input' required <html lang='en'>
  <head>
    <link rel='stylesheet' href='styles.css'/>
  </head>
  <body>
    <label for='search-input'>Pokomon: </label><input id='search-input' required />
    <button id='search-button'>Search</button>
    <div>
      <p id='pokemon-name'></p>
      <p id='pokemon-id'></p>
      <p id='weight'></p>
      <p id='height'></p>
      <p id='types'></p>
      <p id='hp'></p>
      <p id='attack'></p>
      <p id='defense'></p>
      <p id='special-attack'></p>
      <p id='special-defense'></p>
      <p id='speed'></p>
    </div>
  </body>
</html>
/* file: script.js */
const searchButton = document.getElementById('search-button')
const searchInput = document.getElementById('search-input')
///

const pokemonId = document.getElementById('pokemon-id')
const weight = document.getElementById('weight')
const height = document.getElementById('height')
const types = 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')

searchButton.onclick = () => {
  console.log("search click")
  const pok = await fetch(`https://pokeapi-proxy.freecodecamp.rocks/api/pokemon/${searchInput.value.toLowerCase()}`)
  console.log(pok)
  if( !pok.ok ) {
    alert("Pokémon not found")
    return
  }
  const data = await pok.json()
  console.log(data) 
  pokemonId.textContent = data['id']
}
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0

Challenge Information:

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

Your html looks broken.
For eg you have two head tags and two link tags.

You also have other duplicates like duplicate body, duplicate input with duplicate ids.

1 Like


Idk why so happened, that I have double of code

Oh, trouble was in javascript code. Await is not allowed in this place

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.