index.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Задачки</title>
  5. <meta charset="utf-8">
  6. </head>
  7. <body>
  8. <script>
  9. //assign: evaluation
  10. /*var a=5;
  11. var b,c;
  12. b= (a*5);
  13. b= (c=(b/2));
  14. console.log(b);
  15. console.log(c);*/
  16. //----------------------------------------
  17. console.log(2 || 1); //2
  18. console.log(2 || 0); //2
  19. console.log(0 || 2); //2
  20. console.log(0 && 2); //0
  21. console.log(2 && 0); //0
  22. console.log(2 && 1); //1
  23. console.log(2 && 1 && 0); //0
  24. console.log(2 || 1 || 0); //2
  25. console.log(4 && 5 || false); //1
  26. console.log(1 || 0 && 2); //1
  27. //Number: age
  28. /*let date =new Date().getFullYear();
  29. let age=+prompt('','');
  30. let f=date-age;
  31. alert(f);*/
  32. //Number: temperature
  33. //((...°C × 9/5) + 32 = ...°F)
  34. /*let czelsii=prompt('°C','')
  35. let faren= czelsii * 9/5 + 32;
  36. alert(faren+'°F');*/
  37. //Number: divide
  38. /*let num1=+prompt('','');
  39. let num2=+prompt('','');
  40. alert(Math.round(num1)/Math.round(num2));*/
  41. //Number: odd
  42. /*let n=+prompt('','');
  43. if(isNaN(n)){
  44. alert(new Error(' Дичь какая-то'));
  45. }else{
  46. if(n%2==0){
  47. alert('Number: '+ n +' (четное)');
  48. }else{
  49. alert('Number: '+n+' (нечетное)');
  50. }
  51. }*/
  52. //String: greeting
  53. /*let name=prompt('Your name: ','');
  54. alert('Hello, '+name);*/
  55. //String: lexics
  56. /*let badWords=['хуй','лох','дурак'];
  57. let text=prompt('Your text:','');
  58. for(let i=0;i<badWords.length;i++){
  59. if(text.includes(badWords[i])){
  60. alert(new SyntaxError('Следи за языком!'));
  61. break;
  62. }
  63. }*/
  64. //confirm
  65. /*let y=confirm('');
  66. alert(typeof y);*/ //boolean
  67. //Boolean || Boolean: if
  68. /*let y2=confirm('Вы мужчина?');
  69. if(y2){
  70. alert('You are a man');
  71. }else{
  72. alert('That is mean that you are a woman');
  73. }*/
  74. //Array: booleans
  75. /*let y2=confirm('Вы мужчина?');
  76. let y3=confirm();
  77. let y4=confirm();
  78. let y5=confirm();
  79. let arr=[y2,y3,y4,y5];
  80. console.log(arr);*/
  81. //Array: plus
  82. /*let arr=[+prompt('',''),+prompt('','')];
  83. let sum=arr.reduce((s,cur)=>s+=cur);
  84. arr.push(sum);
  85. console.log(arr);*/
  86. //Array: plus string
  87. /*let arr=['Hello,',' Mr.',' President'];
  88. let sum=arr.reduce((s,cur)=>s+=cur);
  89. console.log(sum);*/
  90. //Comparison sizes
  91. /*let sizes={
  92. '40':'6 или L',
  93. '42':'8 или M',
  94. '44':10,
  95. '46':'12 или L',
  96. '48':14,
  97. '50':'16 или XL',
  98. '52':18,
  99. '54':'20 или XXL'
  100. };
  101. let key = prompt('Какой размер перевести вам в USA?','');
  102. alert(sizes[key]);*/
  103. //Ternary
  104. /*confirm('Мужчина или Женщина ?')?alert('Мужчина'):alert('Женщина');*/
  105. //-----------------BluBELT--------------------------------
  106. let house={
  107. firstPadik:[1,2,3,4,5,6,7,8,9],
  108. secondPadik:[10,11,12,13,14,15,16,17,18],
  109. thirdPadik:[19,20,21,22,23,24,25,26,27],
  110. fourthPadik:[28,29,30,31,32,33,34,35,36]
  111. };
  112. let apart=+prompt('Введите номер квартиры','');
  113. let l=0;
  114. for(key in house){
  115. for(let i=0;i<9;i++){
  116. if(apart<=house[key][i]*4 ){
  117. l++;
  118. alert(key+" - "+[++i]+' этаж');
  119. break;
  120. }
  121. }
  122. if(l==1){
  123. break;
  124. }else{
  125. continue;
  126. }
  127. }
  128. </script>
  129. </body>
  130. </html>