main.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. {
  2. var a = 5;
  3. var b, c;
  4. b = (a * 5)
  5. b = (c = (b / 2))
  6. }
  7. {
  8. const year = new Date().getFullYear();
  9. const age = prompt("How old are you?")
  10. age === null ? alert('Please enter your age') : alert(year - age)
  11. }
  12. {
  13. const celsius = +prompt('what is the temperature in celsius ?')
  14. const fahrenheit = celsius * 1.8 + 32;
  15. alert('Faringate temperature ' + fahrenheit)
  16. }
  17. {
  18. const numberOne = +prompt('Please, enter number one')
  19. const numberTwo = +prompt('Please, enter number two')
  20. alert(numberOne / Math.floor(numberTwo))
  21. }
  22. {
  23. const number = +prompt('Please, enter number ')
  24. if (isNaN(number)) {
  25. alert('Please, enter number correct')
  26. } else if (number % 2 === 0) {
  27. alert('number is even')
  28. } else {
  29. alert('number is odd')
  30. }
  31. }
  32. {
  33. const name = prompt("what's your name?")
  34. alert('Hi, ' + name)
  35. }
  36. {
  37. const word = prompt('Enter a word ')
  38. word.includes('dniwe') ? alert('Plese enter correct a word') : alert(word)
  39. }
  40. {
  41. const checkDrunk = confirm('Are you drunk?')
  42. console.log(checkDrunk);
  43. const checkMarried = confirm("are you married?")
  44. if (checkMarried) {
  45. alert('married')
  46. } else {
  47. alert('not married')
  48. }
  49. let myArray = ['Vodka', 'Cognac', 'Whiskey', 'Beer', 'Rum']
  50. const newArray = [...myArray, checkDrunk, checkMarried]
  51. console.log(newArray);
  52. const arrayPlus = newArray[0] + newArray[1]
  53. console.log(arrayPlus);
  54. myArray[2] = arrayPlus
  55. console.log(myArray);
  56. }
  57. {
  58. let myNotebook = {
  59. model: 'Asus',
  60. seria: 'n53',
  61. age: '2011',
  62. batteryСharge: 78,
  63. userName: 'Maxim'
  64. }
  65. console.log(myNotebook);
  66. myNotebook.model = 'Acer'
  67. myNotebook['userName'] = 'Viktoria'
  68. console.log(myNotebook);
  69. }
  70. {
  71. var age = +prompt("Сколько вам лет?", "");
  72. if (age < 18) {
  73. alert("школьник");
  74. }
  75. else {
  76. if (age < 30) {
  77. alert("молодеж");
  78. }
  79. else {
  80. if (age < 45) {
  81. alert("зрелость");
  82. }
  83. else {
  84. if (age < 60) {
  85. alert("закат");
  86. }
  87. else {
  88. if (age > 60) {
  89. alert("как пенсия?");
  90. }
  91. else {
  92. alert("то ли киборг, то ли ошибка");
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. {
  100. const size = prompt('enter size S, M, L, XL, XXL')
  101. if (size === 'S') {
  102. alert('Russian size 40')
  103. } else if (size === 'M') {
  104. alert('Russian size 42')
  105. } else if (size === 'L') {
  106. alert('Russian size 46')
  107. } else if (size === 'XL') {
  108. alert('Russian size 50')
  109. } else if (size === 'XXL') {
  110. alert('Russian size 54')
  111. } else {
  112. alert('Please, enter correct size S, M, L, XL, XXL')
  113. }
  114. }
  115. {
  116. const convectSize = {
  117. S: 40,
  118. M: 42,
  119. L: 46,
  120. XL: 50,
  121. XXL: 54
  122. }
  123. const size = prompt('enter size S, M, L, XL, XXL').toLocaleUpperCase()
  124. if (size === 'S' || size === 'M' || size === 'L' || size === 'XL' || size === 'XXL') {
  125. alert('Russian size ' + convectSize[size])
  126. } else {
  127. alert('Please, enter correct size S, M, L, XL, XXL')
  128. }
  129. }
  130. {
  131. confirm('Are you man?') ? alert('You are man') : alert(' You are woman')
  132. }
  133. {
  134. const floors = 9
  135. const apartmentsInTheFloor = 4
  136. const numberApartment = 81
  137. const apartmentsEntrance = (floors * apartmentsInTheFloor)
  138. const resultEntrance = Math.ceil(numberApartment / apartmentsEntrance)
  139. const remainderApartment = numberApartment % apartmentsEntrance
  140. const resultFlors
  141. if (remainderApartment === 0) {
  142. resultFlors = Math.ceil((remainderApartment + apartmentsEntrance) / apartmentsInTheFloor)
  143. console.log("подьезд " + resultEntrance, "этаж " + resultFlors1);
  144. } else {
  145. resultFlors = Math.ceil(remainderApartment / apartmentsInTheFloor)
  146. console.log("подьезд " + resultEntrance, "этаж " + resultFlors);
  147. }
  148. }