🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 4 Min Lesezeit
0

Creating My Pokémon Collection App: Local Data, Interactivity, and JavaScript Events

↗ Quelle (dev.to)
🗣️ Stimme:




Introduction



When I started this project, my goal was simple: to create a Pokémon collection app where users could explore Pokémon and their details. By combining JavaScript, Node.js, and local data, I built an interactive app that allows users to view Pokémon images, abilities, and types—all while refining my skills with event listeners, dynamic content updates, and more. While I worked on this with a partner, I am going to focus on my work specifically. Here’s how it came together!









Project Overview



This app is designed to showcase a collection of Pokémon images and stats, making it easy for users to click on each Pokémon to view details and switch between main and alternate images with hover interactions. I served the Pokémon data locally, which allowed me to focus on how to render, update, and interact with the data within the app itself.









Setting Up Local Data with db.json



Instead of pulling from an external API, I created a local db.json file with Pokémon data, including attributes like name, type, ability, and image paths. Running a local server on http://localhost:3500/pokemon, I could fetch this data using the fetch method in JavaScript. The simplified setup allowed me to build and test the app entirely offline.









Code Walkthrough



Here’s a look at how I approached key parts of the project.





  1. Fetching Data:
    The first step was to fetch Pokémon data from the local server. I created a getAllPokemon function to handle the fetch request and return the Pokémon details in JSON format.




CODE
   function getAllPokemon() {
return fetch(pokemonURL).then(response => response.json());
}






This function pulls in the Pokémon data from http://localhost:3500/pokemon, which I then use to dynamically render each Pokémon.





  1. Displaying Pokémon:
    To populate the collection, I used a displayPokemons function that iterates through the fetched Pokémon data and renders each item as an image. I also added a click event listener on each image, which opens up the Pokémon details when selected:




CODE
   const displayPokemons = () => {
getAllPokemon().then(pokemonArr => {
pokemonArr.forEach(renderPokemon);
handleClick(pokemonArr[0]); // Display first Pokémon by default
});
}






The renderPokemon function creates an image for each Pokémon, adds styling, and attaches a click event to display details.





  1. Event Listeners: Adding Interactivity
    I used two main types of event listeners in this project: a form submit listener for adding new Pokémon and mouseover/mouseout events to toggle between images. These listeners made the app more engaging and user-friendly.





  • Form Submission:


    To add a new Pokémon, I set up a submit listener on the form, which gathers values from input fields and adds the new Pokémon to the collection. This new Pokémon is rendered without needing to refresh the page:


    CODE
     pokemonForm.addEventListener("submit", event => {
    event.preventDefault();
    const newPokemon = {
    name: event.target.name.value,
    type: event.target.type.value,
    ability: event.target.ability.value,
    image: event.target.image.value,
    altImage: event.target.altImage.value,
    };
    renderPokemon(newPokemon);
    event.target.reset();
    });



    Here, event.preventDefault() stops the form from reloading the page, ensuring a smooth user experience.




  • Mouseover Event for Alternate Images:


    When users hover over the Pokémon’s image in the details section, it switches to an alternate image, simulating an evolution or transformation. The mouseover event triggers this switch, while mouseout reverts it back:


    CODE
     function handleClick(pokemon) {
    const detailImage = el('detail-image');
    detailImage.src = pokemon.image;
    el('detail-name').textContent = pokemon.name;
    el('detail-type').textContent = pokemon.type;
    el('detail-ability').textContent = pokemon.ability;

    detailImage.addEventListener('mouseover', () => {
    detailImage.src = pokemon.altImage;
    });
    detailImage.addEventListener('mouseout', () => {
    detailImage.src = pokemon.image;
    });
    }



    This effect gives users a fun way to interact with each Pokémon and visually explore its characteristics.











Challenges and Learning Points



One challenge was structuring the JavaScript to keep it modular and manageable, as event listeners and dynamic elements can quickly become hard to track. I learned to compartmentalize my code into smaller functions and to use event listeners selectively to optimize performance and readability.









Wrapping Up



This Pokémon collection project was an exciting way to apply JavaScript, experiment with local data fetching, and add engaging event-driven interactivity. Building this app from scratch gave me valuable experience with both front-end and back-end concepts, leaving me inspired to explore more interactive projects in the future.






Check out my project on GitHub!:



https://github.com/kelseyroche/phase-1-project-pokemon

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Creating My Pokémon Collection App: Local Data, Interactivity, and JavaScript Events

Thematisch verwandte Begriffe: Creating, Pokémon, Collection, Local · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...