main.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. //ODD
  2. /*
  3. let number = +prompt('Write your number')
  4. if(number) {
  5. alert("Your number is " + number)
  6. }
  7. else {
  8. alert('You do not write the number')
  9. }
  10. if (number%2==0) {
  11. alert("It's even number")
  12. }
  13. else {
  14. alert("It's odd number")
  15. }
  16. //LEXICS
  17. let str = prompt("Write some text without number ")
  18. if (str.indexOf("1","2","3","4","5","6","7","8","9","0")){
  19. alert("Perfect")
  20. }
  21. else {
  22. alert("You have some mistakes")
  23. }
  24. //BOOLEAN
  25. let sleep = confirm("Are you sleep today?")
  26. let food = confirm("Are you eat today?")
  27. alert(food, sleep)
  28. //IF
  29. let gender = confirm("Are you man?")
  30. if(gender) {
  31. alert("You are man")
  32. }
  33. else {
  34. alert("You are woman")
  35. }
  36. //Sizes
  37. let size = +prompt("Write your size of outerwear?(In USA)") + 2
  38. if(size){
  39. alert("Your size in UK: " + size) //United Kingdom
  40. }
  41. else {
  42. alert("Write a number")
  43. }
  44. let secondsize = confirm("Обхват вашей талии 63 - 65 см?") && confirm("Обхват ваших бедер 89-92 см?")
  45. if(secondsize){
  46. alert("Ваш размер XS")
  47. }
  48. else {
  49. alert("Ваш размер больше XS")
  50. }
  51. //TERNARY
  52. let gender = confirm("Are you woman?") ? alert("woman") : alert("man")
  53. //PROMPT: OR
  54. let age = +prompt ('How old are you?') || alert("Write correct number" )
  55. let year = (2022 - age )
  56. alert("You were born in " + year)
  57. //CONFIRM: OR THIS DAY
  58. let shop = confirm("Shoping?") || alert("You are БЯКА")
  59. //CONFIRM: IF THIS DAY
  60. let shop = confirm("Shoping?")
  61. if(shop){
  62. alert("Let's go")
  63. }
  64. else{
  65. alert("You are БЯКА")
  66. }
  67. //Default: or
  68. {
  69. let name = prompt("Write your name") || String(" Ivan")
  70. let surname = prompt("Write your surname") || String(" Ivanov")
  71. let patronymic = prompt("Write your patronymic") || String(" Ivanovic")
  72. alert(name + surname + patronymic)
  73. }
  74. //Default: if
  75. {
  76. let name = prompt("Write your name")
  77. let surname = prompt("Write your surname")
  78. let patronymic = prompt("Write your patronymic")
  79. if(name){
  80. }
  81. else{
  82. name = String("Ivan")
  83. }
  84. if(surname){
  85. }
  86. else{
  87. surname = String(" Ivanov")
  88. }
  89. if(patronymic){
  90. }
  91. else{
  92. patronymic = String(" Ivanovic")
  93. }
  94. alert(name + surname + patronymic)
  95. }
  96. //Login and password
  97. let login = prompt("Write your login")
  98. let password = prompt("Write your password")
  99. if(login===String("admin") && password===String("qwerty")){
  100. alert("Exactly")
  101. }
  102. else{
  103. alert("You did mistakes in login or password")
  104. }*/
  105. /*
  106. //Currency exchange
  107. let money = prompt("Choose and write down what currency you need to change \n (\"usd\" , \"eur\" , \"pln\")").toUpperCase()
  108. let amount = +prompt("How amount of money you want to change?") || alert("write correctly")
  109. let result , rateBuy , rateSell
  110. if(money===String("USD") || money===String("EUR") || money===String("PLN")){
  111. }
  112. else{alert("Update page and write correctly!")}
  113. if(money===String("USD")){
  114. let change = confirm("You want to sell or buy") ? "sell" : "buy"
  115. if(change==="sell"){
  116. rateSell = 36.9
  117. result = rateSell * amount
  118. alert("You will get : " + result + " UAH" )
  119. }
  120. else{
  121. rateBuy = 38.9
  122. result = rateBuy * amount
  123. alert("You need : " + result + " UAH" )
  124. }
  125. }
  126. if(money===String("EUR")){
  127. let change = confirm("You want to sell or buy") ? "sell" : "buy"
  128. if(change==="sell"){
  129. rateSell = 36
  130. result = rateSell * amount
  131. alert("You will get : " + result + " UAH" )
  132. }
  133. else{
  134. rateBuy = 38
  135. result = rateBuy * amount
  136. alert("You need : " + result + " UAH" )
  137. }
  138. }
  139. if(money===String("PLN")){
  140. let change = confirm("You want to sell or buy") ? "sell" : "buy"
  141. if(change==="sell"){
  142. rateSell = 7.57
  143. result = rateSell * amount
  144. alert("You will get : " + result + " UAH" )
  145. }
  146. else{
  147. rateBuy = 9.57
  148. result = rateBuy * amount
  149. alert("You need : " + result + " UAH" )
  150. }
  151. }
  152. /*
  153. Second variant
  154. let secondmoney = prompt("Choose and write down what currency you need to get \n (\"usd\" , \"eur\" , \"uah\")").toUpperCase()
  155. let rate,result
  156. let amount = +prompt("How amount of money you want to change?") || alert("write correctly")
  157. if(money===String("USD")){
  158. if(secondmoney===String("EUR")){
  159. rate = 1.02
  160. }
  161. else{rate = 36.90}
  162. }
  163. if(money===String("EUR")){
  164. if(secondmoney===String("USD")){
  165. rate = 0.98
  166. }
  167. else{rate = 36.02}
  168. }
  169. if(money===String("UAH")){
  170. if(secondmoney===String("USD")){
  171. rate = 0.027
  172. }
  173. else{rate = 0.028}
  174. }
  175. let change = confirm("You want to change") ? "yes" : "not"
  176. if(change=="yes"){
  177. result = amount * rate
  178. }
  179. alert(result + " : " + secondmoney)
  180. */
  181. /*
  182. //Scissors
  183. let choise = +prompt("Write number of your power : \n 1- Stone \n 2-Scissors \n 3-Paper ")
  184. let randomPc = Math.ceil(Math.random() * 3) //Pc choise
  185. if(choise===1 && randomPc===2){ //STONE
  186. alert("You win")
  187. }
  188. if(choise===1 && randomPc===3){
  189. alert("You losed")
  190. }
  191. if(choise===1 && randomPc===1){
  192. alert("Draw")
  193. }
  194. if(choise===2 && randomPc===3){ //SCISSORS
  195. alert("You win")
  196. }
  197. if(choise===2 && randomPc===1){
  198. alert("You losed")
  199. }
  200. if(choise===2 && randomPc===2){
  201. alert("Draw")
  202. }
  203. if(choise===3 && randomPc===1){ //PAPER
  204. alert("You win")
  205. }
  206. if(choise===3 && randomPc===2){
  207. alert("You losed")
  208. }
  209. if(choise===3 && randomPc===3){
  210. alert("Draw")
  211. }
  212. */
  213. let exc = prompt("Write name of exercise").toUpperCase()
  214. if(exc === "NUMBER:ODD"){
  215. let number = +prompt('Write your number')
  216. if(number) {
  217. alert("Your number is " + number)
  218. }
  219. else {
  220. alert('You do not write the number')
  221. }
  222. if (number%2==0) {
  223. alert("It's even number")
  224. }
  225. else {
  226. alert("It's odd number")
  227. }
  228. }
  229. if(exc === "STRING:LEXICS"){
  230. let str = prompt("Write some text without number ")
  231. if (str.indexOf("1","2","3","4","5","6","7","8","9","0")){
  232. alert("Perfect")
  233. }
  234. else {
  235. alert("You have some mistakes")
  236. }
  237. }
  238. if(exc === "BOOLEAN"){
  239. let sleep = confirm("Are you sleep today?")
  240. let food = confirm("Are you eat today?")
  241. alert(food, sleep)
  242. //IF
  243. let gender = confirm("Are you man?")
  244. if(gender) {
  245. alert("You are man")
  246. }
  247. else {
  248. alert("You are woman")
  249. }
  250. }
  251. if(exc === "BOOLEAN:IF"){
  252. let gender = confirm("Are you man?")
  253. if(gender) {
  254. alert("You are man")
  255. }
  256. else {
  257. alert("You are woman")
  258. }
  259. }
  260. if(exc === "COMPARISON:SIZE"){
  261. let size = +prompt("Write your size of outerwear?(In USA)") + 2
  262. if(size){
  263. alert("Your size in UK: " + size) //United Kingdom
  264. }
  265. else {
  266. alert("Write a number")
  267. }
  268. let secondsize = confirm("Обхват вашей талии 63 - 65 см?") && confirm("Обхват ваших бедер 89-92 см?")
  269. if(secondsize){
  270. alert("Ваш размер XS")
  271. }
  272. else {
  273. alert("Ваш размер больше XS")
  274. }
  275. }
  276. if(exc === "TERNARY"){
  277. let gender = confirm("Are you woman?") ? alert("woman") : alert("man")
  278. }
  279. if(exc === "PROMPT:OR"){
  280. let age = +prompt ('How old are you?') || alert("Write correct number" )
  281. let year = (2022 - age )
  282. alert("You were born in " + year)
  283. }
  284. if(exc === "CONFIRM:OR THIS DAY"){let shop = confirm("Shoping?") || alert("You are БЯКА")}
  285. if(exc === "CONFIRM:IF THIS DAY"){
  286. let shop = confirm("Shoping?")
  287. if(shop){
  288. alert("Let's go")
  289. }
  290. else{
  291. alert("You are БЯКА")
  292. }
  293. }
  294. if(exc === "DEFAULT:OR"){
  295. {
  296. let name = prompt("Write your name") || String(" Ivan")
  297. let surname = prompt("Write your surname") || String(" Ivanov")
  298. let patronymic = prompt("Write your patronymic") || String(" Ivanovic")
  299. alert(name + surname + patronymic)
  300. }
  301. }
  302. if(exc === "DEFAULT:IF"){
  303. let name = prompt("Write your name")
  304. let surname = prompt("Write your surname")
  305. let patronymic = prompt("Write your patronymic")
  306. if(name){
  307. }
  308. else{
  309. name = String("Ivan")
  310. }
  311. if(surname){
  312. }
  313. else{
  314. surname = String(" Ivanov")
  315. }
  316. if(patronymic){
  317. }
  318. else{
  319. patronymic = String(" Ivanovic")
  320. }
  321. alert(name + surname + patronymic)
  322. }
  323. if(exc === "LOGIN AND PASSWORD"){
  324. let login = prompt("Write your login")
  325. let password = prompt("Write your password")
  326. if(login===String("admin") && password===String("qwerty")){
  327. alert("Exactly")
  328. }
  329. else{
  330. alert("You did mistakes in login or password")
  331. }
  332. }
  333. if(exc === "CURRENCY EXCHANGE"){let money = prompt("Choose and write down what currency you need to change \n (\"usd\" , \"eur\" , \"pln\")").toUpperCase()
  334. let amount = +prompt("How amount of money you want to change?") || alert("write correctly")
  335. let result , rateBuy , rateSell
  336. if(money===String("USD") || money===String("EUR") || money===String("PLN")){
  337. }
  338. else{alert("Update page and write correctly!")}
  339. if(money===String("USD")){
  340. let change = confirm("You want to sell or buy") ? "sell" : "buy"
  341. if(change==="sell"){
  342. rateSell = 36.9
  343. result = rateSell * amount
  344. alert("You will get : " + result + " UAH" )
  345. }
  346. else{
  347. rateBuy = 38.9
  348. result = rateBuy * amount
  349. alert("You need : " + result + " UAH" )
  350. }
  351. }
  352. if(money===String("EUR")){
  353. let change = confirm("You want to sell or buy") ? "sell" : "buy"
  354. if(change==="sell"){
  355. rateSell = 36
  356. result = rateSell * amount
  357. alert("You will get : " + result + " UAH" )
  358. }
  359. else{
  360. rateBuy = 38
  361. result = rateBuy * amount
  362. alert("You need : " + result + " UAH" )
  363. }
  364. }
  365. if(money===String("PLN")){
  366. let change = confirm("You want to sell or buy") ? "sell" : "buy"
  367. if(change==="sell"){
  368. rateSell = 7.57
  369. result = rateSell * amount
  370. alert("You will get : " + result + " UAH" )
  371. }
  372. else{
  373. rateBuy = 9.57
  374. result = rateBuy * amount
  375. alert("You need : " + result + " UAH" )
  376. }
  377. }
  378. }
  379. if(exc === "SCISSORS"){
  380. let choise = +prompt("Write number of your power : \n 1- Stone \n 2-Scissors \n 3-Paper ")
  381. let randomPc = Math.ceil(Math.random() * 3) //Pc choise
  382. if(choise===1 && randomPc===2){ //STONE
  383. alert("You win")
  384. }
  385. if(choise===1 && randomPc===3){
  386. alert("You losed")
  387. }
  388. if(choise===1 && randomPc===1){
  389. alert("Draw")
  390. }
  391. if(choise===2 && randomPc===3){ //SCISSORS
  392. alert("You win")
  393. }
  394. if(choise===2 && randomPc===1){
  395. alert("You losed")
  396. }
  397. if(choise===2 && randomPc===2){
  398. alert("Draw")
  399. }
  400. if(choise===3 && randomPc===1){ //PAPER
  401. alert("You win")
  402. }
  403. if(choise===3 && randomPc===2){
  404. alert("You losed")
  405. }
  406. if(choise===3 && randomPc===3){
  407. alert("Draw")
  408. }
  409. }