Build a pokemon search app project

I’m having issue with the test, specifically I think my test should pass step 15 but it doesn’t

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    </head>
    <title>Pokemon Search App</title>
    <link rel="stylesheet" href="styles.css">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale:1.0">
    <body>
      <div id="card">
        <p id="text">V Search for pokemon by name or id V</p>
        <input  required id="search-input"/>
        <button id="search-button">Search</button>
         <p id="pokemon-name"></p>
         <p id="pokemon-id"></p>
         <p id="weight"></p>
         <p id="height"></p>
         <img id="sprite" style="opacity:0;" src=""></img>
         <p id="types"></p>
         <div id="stats">
           <p id="base"class="s">Base</p><p id="base" class="sb">Stats</p>
         <p id="hp" class="s">HP</p><p class="sb hp"></p>
         <p id="attack" class="s">ATK</p><p class="atk sb"></p>
         <p id="defense" class="s">DEF</p><p class="sb def"></p>
         <p id="special-attack"class="s">SATK</p><p class="satk sb"></p>
         <p id="special-defense" class="s">SDEF</p><p class="sdef sb"></p>
         <p class="s" id="speed">SPD</p><p class="sb spd"></p>
         </div>
      </div>
      <script src="script.js"></script>
      </body>
  </html>

JavaScript

const input = document.getElementById("search-input");
const btn = document.getElementById("search-button");
const pName = document.getElementById("pokemon-name");
const id = document.getElementById("pokemon-id");
const weight = document.getElementById("weight");
const height = document.getElementById("height");
const types = document.getElementById("types");
const statsDiv = document.getElementById("stats");
const stats = document.querySelectorAll(".sb");
const img = document.querySelector("#sprite")
const hp = document.querySelector(".hp");
const atk = document.querySelector(".atk");
const def = document.querySelector(".def");
const satk = document.querySelector(".satk");
const sdef = document.querySelector(".sdef");
const spd = document.querySelector(".spd");
let pokeData;
const regex = /(^[a-z]+)[-]?([a-z]+?||[f||m])$|^\d+$/;
let checkedInput;


const getPokemon = async () => {
  try{
 let searchInput = input.value.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
 if (!regex.test(searchInput)){
   alert("This format is not valid, use a name or an id")
} else{
  checkedInput = searchInput
 const response = await fetch(`https://pokeapi-proxy.freecodecamp.rocks/api/pokemon/${checkedInput}`);
  const data = await response.json()
  if (data.id) {
    console.log(data);
    id.textContent = data.id;
    height.textContent = `Height: ${data.height}`;
    weight.textContent = `Weight: ${data.weight}`;
    pName.textContent = data.name.toUpperCase();
    img.src = data.sprites.front_default;
    img.style.opacity = 1;
    hp.textContent = data.stats[0].base_stat;
    atk.textContent = data.stats[1].base_stat;
    def.textContent = data.stats[2].base_stat;
    satk.textContent = data.stats[3].base_stat;
    sdef.textContent = data.stats[4].base_stat;
    spd.textContent = data.stats[5].base_stat;
    types.textContent = data.types.map(typeInfo => typeInfo.type.name);
    
  } else {
    console.log("Pokémon not found");
    alert("Pokémon not found, please check the name or ID.");
  }
  }
} catch (error) {
  alert("Pokémon not found");
};
};
btn.addEventListener("click",getPokemon);

thanks for help in advance

what ahve you tried to investigate the issue?

hint: your issue is with the types

I’m aware my types aren’t there yet but i wanna leave it for later (step 17) to fix, but step 15 doesn’t pass and I’m almost certain everything is how it should be for it

How have you verified that everything should be correct for test 15?

By eye, I’ve put a few pokemon in and compared if everything fits and it does seem so, even when I put in pikachu (the example in step 15) it’s 1:1. Unless im delusional

EDIT: I was delusional, the problem was positioning of the id’s for individual stats, cause even though it looked good on the site with the previous HTML, it didn’t pass the test because the value was SPD:X instead of X…

‘By eye’ is unfortunately a fairly faulty comparison technique.

I see now but I didn’t have anything better in mind :confused:
If there’s a better way to do it I’d be happy to hear about it

You can always use code to check

ignore this, i found the error of my ways

oh yeah I’ve been doing that too but in my head it was simpler to just compare the values haha