diff --git a/README.md b/README.md
index a12177342..6ebec5245 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
-# WEB102 Prework - *Name of App Here*
+# WEB102 Prework - Sea Monster Crowdfunding Application
-Submitted by: **Your Name Here**
+Submitted by: Joel Castro
-**Name of your app** is a website for the company Sea Monster Crowdfunding that displays information about the games they have funded.
+Sea Monster Crowdfunding Application is a website for the company Sea Monster Crowdfunding that displays information about the games they have funded.
-Time spent: **X** hours spent in total
+Time spent: 15 hours spent in total
## Required Features
@@ -15,30 +15,23 @@ The following **required** functionality is completed:
* [ ] The Our Games section initially displays all games funded by Sea Monster Crowdfunding
* [ ] The Our Games section has three buttons that allow the user to display only unfunded games, only funded games, or all games.
-The following **optional** features are implemented:
-
-* [ ] List anything else that you can get done to improve the app functionality!
## Video Walkthrough
Here's a walkthrough of implemented features:
-
-
-GIF created with ...
-
+
-## Notes
+GIF created with ... QuickTime Player
-Describe any challenges encountered while building the app.
+## Notes
+Went through the use of DOM, combining both JavaScript and HTML together.
+Interaction between creating new elements to be displayed in the HTML website, being created in the JS file
## License
- Copyright [yyyy] [name of copyright owner]
+ Copyright [2024] [Joel Castro]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/index.js b/index.js
index 86fe7d438..f71200d00 100644
--- a/index.js
+++ b/index.js
@@ -30,26 +30,37 @@ function addGamesToPage(games) {
// loop over each item in the data
+ for (let g = 0; g < games.length; g++) {
+ // create a new div element, which will become the game card
+ let div = document.createElement('div');
+
+ // add the class game-card to the list
+ div.classList.add("game-card");
+
+ // set the inner HTML using a template literal to display some info
+ // about each game
+ // TIP: if your images are not displaying, make sure there is space
+ // between the end of the src attribute and the end of the tag ("/>")
+ let display = `
+
+
${ games[g].name }
+Pledged: ${ games[g].pledged }
+ `; + div.innerHTML = display; + + + // append the game to the games-container + let gcont = document.getElementById("games-container"); + gcont.appendChild(div); - // create a new div element, which will become the game card - - - // add the class game-card to the list - - - // set the inner HTML using a template literal to display some info - // about each game - // TIP: if your images are not displaying, make sure there is space - // between the end of the src attribute and the end of the tag ("/>") - - - // append the game to the games-container + } + } // call the function we just defined using the correct variable // later, we'll call this function using a different list of games - +addGamesToPage(GAMES_JSON); /************************************************************************************* * Challenge 4: Create the summary statistics at the top of the page displaying the @@ -61,19 +72,28 @@ function addGamesToPage(games) { const contributionsCard = document.getElementById("num-contributions"); // use reduce() to count the number of total contributions by summing the backers +const contributors= GAMES_JSON.reduce((ppl, game)=>{ + return ppl + game.backers; +},0); // set the inner HTML using a template literal and toLocaleString to get a number with commas - +contributionsCard.innerHTML = `${contributors.toLocaleString("en-US")}`; // grab the amount raised card, then use reduce() to find the total amount raised const raisedCard = document.getElementById("total-raised"); +const donations = GAMES_JSON.reduce((amt,game)=>{ + return amt + game.pledged; +},0); + // set inner HTML using template literal +raisedCard.innerHTML = `$${donations.toLocaleString("en-US")}`; // grab number of games card and set its inner HTML const gamesCard = document.getElementById("num-games"); +gamesCard.innerHTML = GAMES_JSON.length; /************************************************************************************* @@ -87,9 +107,12 @@ function filterUnfundedOnly() { deleteChildElements(gamesContainer); // use filter() to get a list of games that have not yet met their goal - + let unfunded = GAMES_JSON.filter((game)=>{ + return game.pledged