index.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Exercises</title>
  6. </head>
  7. <body>
  8. <script>
  9. let exercise=prompt('','');
  10. switch(exercise){
  11. case 'switch: sizes':
  12. let size=prompt('Введите размер','');
  13. switch(size){
  14. case '40':alert('6 или L');
  15. break;
  16. case '42':alert('8 или M');
  17. break;
  18. case '44':alert('10');
  19. break;
  20. case '46':alert('12 или L');
  21. break;
  22. case '48':alert('14');
  23. break;
  24. case '50':alert('16 или XL');
  25. break;
  26. case '52':alert('18');
  27. break;
  28. case '54':alert('20 или XXL');
  29. break;
  30. }
  31. break;
  32. case 'prompt: or':prompt('Введите возраст','')||alert(new Error('Error'));
  33. break;
  34. case 'confirm: or this days':confirm('Shopping?')||alert('Ты - бяка');
  35. break;
  36. case 'confirm: if this days':
  37. if(confirm('Shopping?')){
  38. alert('oK');
  39. }else{
  40. alert('Ты - бяка');
  41. }
  42. break;
  43. case 'triple prompt,default: or':
  44. let name=prompt('name','')||'John';
  45. let secondName=prompt('secondName','')||'Johnson';
  46. let surname=prompt('surname','')||'Pupkovich';
  47. alert(name+' '+secondName+' '+surname);
  48. break;
  49. case 'default: if':
  50. let Name=prompt('name','');
  51. if(Name==0||Name==undefined){
  52. Name='John'
  53. }
  54. let secondName2=prompt('secondName','');
  55. if(secondName2==0||secondName2==undefined){
  56. secondName2='Johnson';
  57. }
  58. let surname2=prompt('surname','');
  59. if(surname2==0||surname2==undefined){
  60. surname2='Pupkovich';
  61. }
  62. alert(Name+' '+secondName2+' '+surname2);
  63. break;
  64. case 'login and password':
  65. let name3='John';
  66. let pass='qwerty';
  67. let ask=prompt('Your name?','');
  68. if(ask!==name3){
  69. alert('Error name OR pass ...');
  70. }else{
  71. let ask2=prompt('Your password?');
  72. if(ask2!==pass){
  73. alert('Error name OR pass ...');
  74. }else{
  75. alert('Congratulation');
  76. }
  77. }
  78. break;
  79. case 'scissors':
  80. let ask2=prompt('Камень, нижницы или бумага ?','');
  81. let answer='';
  82. let num=Math.round(Math.random()*10);
  83. if(num>0&&num<=3){
  84. answer='камень';
  85. }else{
  86. if(num>=4&&num<=7){
  87. answer='бумага';
  88. }else{
  89. answer='ножницы';
  90. }
  91. }
  92. console.log(answer);
  93. if(ask2==answer){
  94. alert('Вы выиграли');
  95. }else{
  96. alert('Вы проиграли ');
  97. }
  98. break;
  99. }
  100. //Black belt
  101. let key2=Math.random();
  102. let key=key2>0.1&&key2<=0.4?'ножницы': key2>0.5? 'бумуга': 'камень';
  103. console.log(key);
  104. </script>
  105. </body>
  106. </html>