From bd06ca969c3771271d94f5121036cef5c64357d2 Mon Sep 17 00:00:00 2001 From: urvashiparashar Date: Sat, 14 May 2022 00:03:17 +0530 Subject: [PATCH 1/2] VITFED21 --- index.html | 35 ++++++++++++++++------------------- src/app.js | 54 +++++++++++++++++++++++++++++------------------------- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/index.html b/index.html index 62790f2..30dc2b4 100644 --- a/index.html +++ b/index.html @@ -1,25 +1,22 @@ - - - - - + + + + Super Wars - - + + - +
-
-
-
-
-
-
+
+
+
- - - - - + + + + \ No newline at end of file diff --git a/src/app.js b/src/app.js index cc43cc2..0bc45c2 100644 --- a/src/app.js +++ b/src/app.js @@ -1,24 +1,4 @@ -const PLAYERS = [ - "Spiderman", - "Captain America", - "Wonderwoman", - "Popcorn", - "Gemwoman", - "Bolt", - "Antwoman", - "Mask", - "Tiger", - "Captain", - "Catwoman", - "Fish", - "Hulk", - "Ninja", - "Black Cat", - "Volverine", - "Thor", - "Slayer", - "Vader", - "Slingo" +const PLAYERS = ["Spiderman","Captain America", "Wonderwoman","Popcorn", "Gemwoman", "Bolt","Antwoman","Mask","Tiger", "Captain","Catwoman","Fish", "Hulk","Ninja","Black Cat","Volverine","Thor","Slayer","Vader", "Slingo" ]; // initialize players with image and strength @@ -26,15 +6,34 @@ const initPlayers = (players) => { let detailedPlayers = []; // Create players using for loop // Type your code here - + for (var i = 0; i < players.length; i++) { + detailedPlayers[i] = { + name: players[i], + strength: getRandomStrength(), + image: "images/super-" + (i + 1) + ".png", + }; + if (i % 2 == 0) { + detailedPlayers[i].type = "hero"; + } else { + detailedPlayers[i].type = "villain"; + } + } return detailedPlayers; } - +function herovillian(n) { + if (n % 2 == 0) { + return "hero"; + } else { + return "villain"; + } +} // getting random strength const getRandomStrength = () => { // Return a random integer (0,100] // Note: You can use Math.random() and Math.ceil() -} + let s = Math.ceil(Math.random() * (100 - 1) + 1); + return s; +}; const buildPlayers = (players, type) => { let fragment = ''; @@ -42,9 +41,14 @@ const buildPlayers = (players, type) => { // Loop through players and accumulate HTML template // depending of type of player(hero|villain) // Type your code here + for (var i = 0; i < players.length; i++) { + if (players[i].type == type) { + fragment += `
${players[i].name}
${players[i].strength}
`; + } + } return fragment; -} +}; // Display players in HTML const viewPlayers = (players) => { From dfb64a26938079822dc775855bc3ff425e31d16a Mon Sep 17 00:00:00 2001 From: urvashiparashar Date: Sat, 14 May 2022 00:08:01 +0530 Subject: [PATCH 2/2] VITFED21 --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 30dc2b4..2ef44b8 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,7 @@
- Made with by VITFED20 + Made with by VITFED21