file.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. // html tree
  2. let body = {
  3. tagName: "body",
  4. subTags: [
  5. {tagName: 'div',
  6. subTags:[
  7. {tagName:'br'},
  8. {tagName:'span', text: 'Enter a data please:'},
  9. {tagName:'input', attrs:{type:'text', id:'name'}},
  10. {tagName:'input', attrs:{type:'text', id:'surname'}}
  11. ]},
  12. {tagName: 'div',
  13. subTags:[
  14. {tagName:'button', text:'OK', attrs:{id:'ok'}},
  15. {tagName:'button', text:'Cancel', attrs:{id:'cancel'}}
  16. ]}
  17. ]
  18. }
  19. body.subTags[1].subTags[1].text
  20. body.subTags[0].subTags[3].attrs.id
  21. // declarative fields
  22. let notebook = {
  23. brand: prompt('Enter brand'),
  24. type: prompt('Enter type'),
  25. model: prompt('Enter model'),
  26. ram: +prompt('Enter ram'),
  27. size: prompt('Size'),
  28. weight: +prompt('Weight'),
  29. resolution: {
  30. width: +prompt ('Width'),
  31. height: +prompt ('Height'),
  32. },
  33. };
  34. let phone = {
  35. brand: prompt('Enter brand'),
  36. model: prompt('Enter model'),
  37. ram: +prompt('Enter ram'),
  38. color: prompt('Enter color'),
  39. };
  40. let person = {
  41. name: prompt('Enter a name'),
  42. surname: prompt('Enter a surname'),
  43. married: confirm(),
  44. }
  45. // object links
  46. let person1 = {
  47. name:prompt('Enter a name'),
  48. smartphone:{ owner:person1},
  49. laptop:{ owner:person1}
  50. }
  51. // imperative array fill 3
  52. let array = [];
  53. array[0] = +prompt();
  54. array[1] = +prompt();
  55. array[2] = +prompt();
  56. // while confirm
  57. let qvestion = '';
  58. while(qvestion != true){
  59. qvestion = confirm('are you batman?')}
  60. // array fill
  61. let array1 = [];
  62. let filling = '';
  63. while(filling != null){
  64. filling = prompt('введите число'),
  65. array1.push(filling);
  66. }
  67. // array fill nopush\
  68. let array2 = [];
  69. let i = 0;
  70. let filling1 = '';
  71. while(filling1 != null){
  72. filling1 = prompt('введите число')
  73. array2[i] = filling1;
  74. i++
  75. }
  76. // infinite probability:
  77. // через for
  78. for(i = 0,b=1;i<0.9;b++){
  79. i = Math.random()};
  80. alert(`Прошло ${b} итерации`)
  81. // через while
  82. let b = 0;
  83. let a = 0;
  84. while(b<0.9){
  85. b = Math.random()
  86. a++}
  87. alert(`${b} iteration`)
  88. // empty loop
  89. let value = '';
  90. while(value != prompt());
  91. // progression sum
  92. let sum = 0;
  93. for(i = 1; i < 50; i+=3){
  94. sum = sum + i}
  95. console.log(sum);
  96. // chess one line
  97. let c = '';
  98. for(y = 0;y < 16;y++){
  99. if(y % 2 === 1){
  100. c = c + '#'}
  101. else {
  102. c = c + '.'}}
  103. // numbers
  104. let str = ''
  105. for(i=0;i<10;i++){
  106. str += '\n'
  107. for(j=0;j<10;j++){
  108. str+=j
  109. }
  110. }console.log(str)
  111. // chess
  112. let strn = ''
  113. for(f = 0;f<12;f++){
  114. strn += '\n'
  115. for(y = 0;y < 12;y++){
  116. if(y % 2 === 1){
  117. strn += '#'}
  118. else {
  119. strn += '.'}}}
  120. // cubes(?????????)<
  121. // multiply table
  122. debugger
  123. let result = '\n';
  124. for (let f = 1;f < 11; f++){
  125. for(let j = 1; j < 11; j++){
  126. result += [f*j] + ' ';
  127. }
  128. result += '\n'
  129. }
  130. console.log(result)
  131. // matrix to html table(????????)
  132. // не понял с этого задания>