main.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. // const taskName = prompt('Enter task name');
  2. // switch (taskName) {
  3. // case 'switch: sizes': const sizeRus = prompt('enter size');
  4. // switch (sizeRus) {
  5. // case '40': alert('I 38, GB 8, USA 6');
  6. // break;
  7. // case '42': alert('I 40, GB 10, USA 8');
  8. // break;
  9. // case '44': alert('I 42, GB 12, USA 10');
  10. // break;
  11. // case '46': alert('I 44, GB 14, USA 12');
  12. // break;
  13. // case '48': alert('I 46, GB 16, USA 14');
  14. // break;
  15. // case '50': alert('I 48, GB 18, USA 16');
  16. // break;
  17. // };
  18. // break;
  19. // case 'switch: if': let color = prompt("Введите цвет","");
  20. // if (color === "red") {
  21. // document.write("<div style='background-color: red;'>красный</div>");
  22. // document.write("<div style='background-color: black; color: white;'>черный</div>");
  23. // }
  24. // else if (color === "black") {
  25. // document.write("<div style='background-color: black; color: white;'>черный</div>");
  26. // }
  27. // else if (color === "blue") {
  28. // document.write("<div style='background-color: blue;'>синий</div>");
  29. // document.write("<div style='background-color: green;'>зеленый</div>");
  30. // }
  31. // else if (color === "green") {
  32. // document.write("<div style='background-color: green;'>зеленый</div>");
  33. // }
  34. // else {
  35. // document.write("<div style='background-color: gray;'>Я не понял</div>");
  36. // };
  37. // break;
  38. // case 'prompt: or': const age = +(prompt('Your age')); console.log(age);
  39. // const yearPresent = 2021;
  40. // let ageNew;
  41. // if ( age == "" || age === null ) {
  42. // ageNew = +prompt('Please writing your age');
  43. // }; console.log(ageNew);
  44. // if (ageNew === null || ageNew == "") {
  45. // alert('It is not interested for you');
  46. // };
  47. // if (age !== "" || ageNew !== "" || typeof(age) === 'number') {
  48. // const yearBirth = yearPresent - ageNew;
  49. // const yearBirth1 = yearPresent - age;
  50. // alert(` ${yearBirth1} ${yearBirth}`);
  51. // };
  52. // break;
  53. // case 'confirm: or this days': const shoping = confirm('Shoping?'); console.log(shoping);
  54. // shoping || alert(`you are biaka`);
  55. // break;
  56. // case 'confirm: if this days': const shoping = confirm('Shoping?'); console.log(shoping);
  57. // if (shoping === false) {
  58. // alert(`you are biaka`);
  59. // };
  60. // break;
  61. // case 'triple prompt': const surname = prompt('enter surname');
  62. // const userName = prompt('enter name');
  63. // const patronymic = prompt('patronymic');
  64. // alert(`Full name ${surname} ${userName} ${patronymic} `);
  65. // break;
  66. // case 'default: or': const surname = prompt('enter surname');
  67. // const userName = prompt('enter name');
  68. // const patronymic = prompt('patronymic');
  69. // alert(`Full name ${surname || 'Ivanov'} ${userName || 'Ivanov'} ${patronymic || 'Ivanov'} `);
  70. // break;
  71. // case 'default: if': let surname = prompt('enter surname');
  72. // let userName = prompt('enter name');
  73. // let patronymic = prompt('patronymic');
  74. // //1)
  75. // if (surname === null || surname === "") {
  76. // surname = 'Ivanov';
  77. // };
  78. // if (userName === null || userName === ""){
  79. // userName = 'Ivanov';
  80. // };
  81. // if (patronymic === null || patronymic ==="") {
  82. // patronymic = 'Ivanov';
  83. // } ;
  84. // alert(`Full name ${surname} ${userName} ${patronymic} `);
  85. // //2)
  86. // if ((surname === null || surname === "") && (userName === null || userName === "") && (patronymic === null || patronymic ==="") ) {
  87. // alert('Ivanov Ivanov Ivanov');
  88. // } else if (surname === null || surname === "") {
  89. // surname = 'Ivanov';
  90. // alert(`Full name ${surname} ${userName} ${patronymic} `);
  91. // } else if (userName === null || userName === ""){
  92. // userName = 'Ivanov';
  93. // alert(`Full name ${surname} ${userName} ${patronymic} `);
  94. // } else if (patronymic === null || patronymic ==="") {
  95. // patronymic = 'Ivanov';
  96. // alert(`Full name ${surname} ${userName} ${patronymic} `);
  97. // } ;
  98. // break;
  99. // case 'login and password': const login = "admin";
  100. // const password = "qwerty";
  101. // const useLogin = prompt('Enter login');
  102. // let usePassword;
  103. // if (login === useLogin) {
  104. // usePassword = prompt('Enter password');
  105. // };
  106. // if (login !== useLogin || password !== usePassword) {
  107. // alert('Error');
  108. // } else alert('Good!');
  109. // break;
  110. // case 'currency calc': const currency = prompt('select currency: usd or eur' ).toLowerCase();
  111. // let monyHr;
  112. // switch (currency) {
  113. // case 'usd': monyHr = 27;
  114. // break;
  115. // case 'eur': monyHr = 30;
  116. // break;
  117. // };
  118. // const hryvnias = prompt('how much UAH');
  119. // alert(`${currency} ${hryvnias / monyHr}`);
  120. // break;
  121. // case 'currency calc: two rates': const currency = prompt('select currency: usd or eur' ).toLowerCase();
  122. // const question = confirm('Do You want to buy currency?');
  123. // const amount = prompt('Money');
  124. // let monyHr;
  125. // switch (currency) {
  126. // case 'usd': monyHr = 27;
  127. // break;
  128. // case 'eur': monyHr = 30;
  129. // break;
  130. // };
  131. // question ? alert(`${currency} ${amount / monyHr}`) : alert(`hryvnias ${amount * monyHr}`);
  132. // break;
  133. // case 'currency calc: if': const currency = prompt('select currency: usd or eur' ).toLowerCase();
  134. // const question = confirm('Do You want to buy currency?');
  135. // const amount = prompt('Money');
  136. // let monyHr;
  137. // if (currency === 'usd') {
  138. // monyHr = 27;
  139. // };
  140. // if (currency === 'eur') {
  141. // monyHr = 30;
  142. // };
  143. // if (question) {
  144. // alert(`${currency} ${amount / monyHr}`);
  145. // } else alert(`hryvnias ${amount * monyHr}`);
  146. // break;
  147. // case 'scissors': const things = ['rock', 'scissors', 'paper'];
  148. // const userThing = prompt('choose rock or paper or scissors');
  149. // const randomThings = things[ Math.floor(Math.random()*things.length)];
  150. // alert(randomThings);
  151. // if ((userThing === 'rock') && (randomThings === 'scissors')) {
  152. // alert('you are winner!');
  153. // } else if ((userThing === 'scissors') && (randomThings === 'paper')) {
  154. // alert('you are winner!');
  155. // } else if ((userThing === 'paper') && (randomThings === 'rock')) {
  156. // alert('you are winner!');
  157. // } else if (randomThings === userThing) {
  158. // alert('no one is a winner');
  159. // } else alert('you lose');
  160. // break;
  161. // case 'Задание на синий пояс': let ratios = {
  162. // usd: 25.6,
  163. // eur: 29
  164. // };
  165. // const currency = prompt('select currency: usd or eur' ).toLowerCase();
  166. // const question = confirm('Do You want to buy currency?');
  167. // const amount = prompt('Money');
  168. // const monyHr = ratios[currency];
  169. // question ? alert(`${currency} ${amount / monyHr}`) : alert(`hryvnias ${amount * monyHr}`);
  170. // break;
  171. // case 'real data': const amountMoney = prompt('Enter Money');
  172. // fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
  173. // .then(data => {
  174. // console.log(data.rates.UAH)
  175. // alert(`UAN ${amountMoney * data.rates.UAH}`)
  176. // });
  177. // break;
  178. // };
  179. //Task
  180. const things = ['rock', 'scissors', 'paper'];
  181. const userThing = prompt('choose rock or paper or scissors');
  182. const randomThings = things[ Math.floor(Math.random()*things.length)];
  183. alert(randomThings);
  184. ((userThing === 'rock') && (randomThings === 'scissors') && !(alert('you are winner!'))) ||
  185. ((userThing === 'scissors') && (randomThings === 'paper') && !(alert('you are winner!'))) ||
  186. ((userThing === 'paper') && (randomThings === 'rock') && !(alert('you are winner!'))) ||
  187. ((randomThings === userThing) && !(alert('no one is a winner'))) ||
  188. !(alert('you lose'));