hw_index.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <header>
  2. CONTENT
  3. </header>
  4. <body>
  5. <button onclick="odd();">odd</button>
  6. <button onclick="lexics();">lexics</button>
  7. <button onclick="boolean();">Boolean</button>
  8. <button onclick="boolean_if();">boolean_if</button>
  9. <button onclick="sizes();">sizes</button>
  10. <button onclick="ternary();">Ternary</button>
  11. <button onclick="prompt_or();">prompt_or</button>
  12. <button onclick="orThisDays();">orThisDays</button>
  13. <button onclick="ifThisDays();">ifThisDays</button>
  14. <button onclick="defaultOr();">defaultOr</button>
  15. <button onclick="defaultIf();">defaultIf</button>
  16. <button onclick="loginAndPassword();">loginAndPassword</button>
  17. <button onclick="currencyExchange();">currencyExchange</button>
  18. <button onclick="scissors();">scissors</button>
  19. <button onclick="blackBelt();">blackBelt</button>
  20. <script>
  21. function odd() {
  22. const a = +prompt("Enter a number");
  23. if (typeof a !== 'number') alert("non correct type");
  24. if (a % 2) alert("odd");
  25. else alert("ever");
  26. }
  27. function lexics() {
  28. let phrase = prompt("Enter a phrase").toLowerCase();
  29. if (phrase.indexOf("xyz") < 0 &&
  30. phrase.indexOf("234") < 0 &&
  31. phrase.indexOf("cvb") < 0)
  32. alert("No fucking sheet...");
  33. else alert("не хрен ругаться");
  34. }
  35. function boolean() {
  36. var b = confirm("Say Yes or No, please");
  37. alert(b);
  38. }
  39. function boolean_if() {
  40. var b = confirm("Are You MAN? or WOMEN");
  41. if (b == true) alert("You are MAN");
  42. else alert("You are WOMEN")
  43. }
  44. function sizes() {
  45. let sizePants = +prompt("Enter Your size of pants ");
  46. let hipSize = +prompt("Enter Your hip size sm");
  47. let sizeSocks = +prompt("Enter Your size of socks");
  48. usaPants = "-";
  49. sizeUsa = "-";
  50. socksUsa = "-";
  51. if (sizePants == 40) usaPants = "S or 6";
  52. if (sizePants == 42) usaPants = "M or8";
  53. if (sizePants == 44) usaPants = "10";
  54. if (sizePants == 46) usaPants = "L or 12";
  55. if (sizePants == 48) usaPants = "14";
  56. if (sizePants == 50) usaPants = "XL or 16";
  57. if (sizePants == 52) usaPants = "18";
  58. if (sizePants == 54) usaPants = "XXL or 20";
  59. if (hipSize >= 89 && hipSize <= 92) sizeUsa = "XXS";
  60. if (hipSize >= 93 && hipSize <= 96) sizeUsa = "XS";
  61. if (hipSize >= 97 && hipSize <= 101) sizeUsa = "S";
  62. if (hipSize >= 102 && hipSize <= 104) sizeUsa = "M";
  63. if (hipSize >= 105 && hipSize <= 108) sizeUsa = "L";
  64. if (hipSize >= 109 && hipSize <= 112) sizeUsa = "XL";
  65. if (hipSize >= 113 && hipSize <= 117) sizeUsa = "XXL";
  66. if (hipSize >= 118 && hipSize <= 122) sizeUsa = "XXXL";
  67. if (sizeSocks == 21) socksUsa = "8";
  68. if (sizeSocks == 23) socksUsa = "9";
  69. if (sizeSocks == 25) socksUsa = "10";
  70. if (sizeSocks == 27) socksUsa = "11";
  71. alert("Your Usa size of pants is:\n" + usaPants + "\n" + 'Your USA hip size is:\n' + sizeUsa + "\n" + "Your USA socks size is:\n" + socksUsa);
  72. }
  73. function ternary() {
  74. confirm("Are You MAN? or WOMEN") ? alert("You are MAN") : alert("You are WOMEN");
  75. }
  76. function prompt_or() {
  77. prompt("Enter Age") ? alert("OK") : alert("Missing age");
  78. }
  79. function orThisDays() {
  80. confirm("ШОПИНГ???") ? alert("OK") : alert("Ты-бяка");
  81. }
  82. function ifThisDays() {
  83. if (confirm("ШОПИНГ???"))
  84. alert("OK");
  85. else
  86. alert("Ты-бяка");
  87. }
  88. function defaultOr() {
  89. let sName = prompt("Enter surname") || "Иванов";
  90. let name = prompt("Enter name") || "Иван";
  91. let fName = prompt("Enter father`s name") || "Иванович";
  92. alert(sName + " " + name + " " + fName);
  93. }
  94. function defaultIf() {
  95. let sName = prompt("Enter surname");
  96. if (!sName)
  97. sName = "Иванов";
  98. let name = prompt("Enter name");
  99. if (!name)
  100. name = "Иван";
  101. let fName = prompt("Enter father`s name");
  102. if (!fName)
  103. fName = "Иванович";
  104. alert(sName + " " + name + " " + fName);
  105. }
  106. function loginAndPassword() {
  107. let rightLogin = "admin";
  108. let rigthtPass = "qwerty";
  109. let login = prompt("Enter login");
  110. let valid = login === rightLogin;
  111. if (valid) {
  112. let pass = prompt("Enter password");
  113. valid = pass === rigthtPass;
  114. }
  115. if (valid)
  116. alert("Congrats!!");
  117. else
  118. alert("wrong credentials!!! SUKA");
  119. }
  120. function currencyExchange() {
  121. let typeCurrency = prompt("Enter currency type").toLowerCase();
  122. rate = 1.0;
  123. let isBuy = confirm("Sale?");
  124. if (typeCurrency === "usd")
  125. rate = isBuy ? 40 : 43;
  126. else if (typeCurrency === "eur")
  127. rate = isBuy ? 39 : 41;
  128. else if (typeCurrency === "pln")
  129. rate = isBuy ? 7.5 : 7.8;
  130. let sumMoney = +prompt("Enter amount");
  131. alert((sumMoney * rate) + "UAH");
  132. }
  133. function scissors() {
  134. let userBid = +prompt("Enter bid 1-3 1=stone 2= scissors 3= paper");
  135. if (1 >= userBid >= 3) {
  136. alert(" Non correct bid");
  137. }
  138. else {
  139. let machimeBid = Math.floor(Math.random() * 3 + 1);
  140. alert(userBid + " " + machimeBid);
  141. if (userBid == machimeBid) {
  142. alert("Nobody win");
  143. }
  144. else {
  145. if ((userBid - machimeBid) > 1 ||
  146. ((machimeBid - userBid) <= 1 &&
  147. (machimeBid - userBid) >= 0))
  148. alert("Congrats, You WIN!");
  149. else
  150. alert("Sorry, You WoN");
  151. }
  152. }
  153. }
  154. function blackBelt() {
  155. let userBid = +prompt("Enter bid 1-3 1=stone 2= scissors 3= paper");
  156. let machimeBid = Math.floor(Math.random() * 3 + 1);
  157. alert(userBid + " " + machimeBid);
  158. userBid == machimeBid ?
  159. alert("Nobody win") :
  160. ((userBid - machimeBid) > 1 ||
  161. ((machimeBid - userBid) <= 1 &&
  162. (machimeBid - userBid) >= 0)) ?
  163. alert("Congrats, You WIN!")
  164. :
  165. alert("Sorry, You WoN");
  166. }
  167. </script>
  168. </body>