SHARE
TWEET

littlejs

a guest Oct 10th, 2019 75 in 351 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///////
  2. => JS
  3. ///////
  4.  
  5.   let hero1 = {
  6.     heroName: "",
  7.     ad : 3
  8.   };
  9.  
  10.   let hero2 = {
  11.     heroName: "",
  12.     ad : 7
  13.   };
  14.  
  15.  
  16.  
  17. function ask() {
  18. hero1.heroName = prompt("Hero1 Name: ");
  19. hero1.ad = prompt("Hero1 Attack Damage: ");
  20.  
  21. hero2.heroName = prompt("Hero2 Name: ");
  22. hero2.ad = prompt("Hero2 Attack Damage: ");
  23.  
  24. totalAd = parseFloat(hero1.ad) + parseFloat(hero2.ad);
  25.  
  26. console.log("Hero1 name is " + hero1.heroName + " and has AD = " + hero1.ad);
  27. console.log("Hero2 name is " + hero2.heroName + " and has AD = " + hero2.ad);
  28. console.log("Total AD = " + totalAd);
  29. }
  30.  
  31.  
  32. /////
  33. html
  34. /////
  35.  
  36. <!DOCTYPE html>
  37. <html>
  38.  
  39. <head>
  40.   <meta charset="UTF-8">
  41.   <meta name="viewport" content="width=device-width, initial-scale=1">
  42.   <title>Asgn</title>
  43.  
  44.   <style>
  45.     body {
  46.       text-align: center;
  47.       margin-top: 50%;}
  48.  
  49.     p { color: grey;
  50.         size: 24px;}
  51.  
  52.   </style>
  53. </head>
  54.  
  55. <body>
  56.  
  57.   <h1>Choose your team:</h1>
  58.    
  59.   <h3>
  60.     <button onclick="ask()"> select </button>
  61.   </h3>
  62.   <h3 id="ask"></h3>
  63.  
  64. <script src="main.js"></script>
  65.  
  66. </body>
  67. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top