diff --git a/src/app.js b/src/app.js index cc43cc2..f08d774 100644 --- a/src/app.js +++ b/src/app.js @@ -25,7 +25,14 @@ const PLAYERS = [ const initPlayers = (players) => { let detailedPlayers = []; // Create players using for loop - // Type your code here + players.forEach((player, i) => { + detailedPlayers.push({ + name: player, + image: "images/super-" + (i + 1) + ".png", + strength: getRandomStrength(), + type: i % 2 == 0 ? "hero" : "villain" + }); + }) return detailedPlayers; } @@ -34,14 +41,23 @@ const initPlayers = (players) => { const getRandomStrength = () => { // Return a random integer (0,100] // Note: You can use Math.random() and Math.ceil() -} + return Math.ceil(Math.random() * (100 - 1) + 1); +}; const buildPlayers = (players, type) => { let fragment = ''; // Loop through players and accumulate HTML template // depending of type of player(hero|villain) - // Type your code here + players.forEach((player) => { + fragment += ` +