somejs

Download Raw Clone


  1. let hero1 = {
  2. heroName: "",
  3. ad : 3
  4. };
  5. let hero2 = {
  6. heroName: "",
  7. ad : 7
  8. };
  9. function ask() {
  10. hero1.heroName = prompt("Hero1 Name: ");
  11. hero1.ad = prompt("Hero1 Attack Damage: ");
  12. hero2.heroName = prompt("Hero2 Name: ");
  13. hero2.ad = prompt("Hero2 Attack Damage: ");
  14. // afisarea celor doi eroi
  15. console.log("Hero1 name is " + hero1.heroName + " and has AD = " + hero1.ad);
  16. console.log("Hero2 name is " + hero2.heroName + " and has AD = " + hero2.ad);
  17. }
  18. function totalAD(){
  19. totalAd = parseFloat(hero1.ad) + parseFloat(hero2.ad) + parseFloat(hero3.ad) + parseFloat(hero4.ad) + parseFloat(hero5.ad);
  20. console.log("Total AD = " + totalAd);
  21. }
  22. function inputAttackDamage( heroName, ad) {
  23. //herox.heroName = prompt("Numele eroului?");
  24. ad = prompt("Care este forta lui: " +heroName + " ?");
  25. return parseFloat(ad);
  26. }
  27. function createHero(heroName, ad) {
  28. prompt("New Hero Name: ") + this.heroName;
  29. this.heroName = heroName;
  30. this.ad = inputAttackDamage();
  31. this.ad = ad;
  32. console.log("Eroul cu numele " + heroName + " si attack dmg =" + ad + " a fost creat");
  33. }
  34. function corefunction() {
  35. hero3 = createHero();
  36. hero4 = createHero();
  37. hero5 = createHero();
  38. totalattackdamage = totalAD();
  39. console.log(totalattackdamage);
  40. }

Raw paste data: