script.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. let body = {
  2. tagName: `body`,
  3. subTags : [
  4. {
  5. tagName: `div`,
  6. subTags: [
  7. {
  8. tagName:`span`,
  9. text:'Enter a data please:'
  10. },
  11. {
  12. tagName: `br`
  13. },
  14. {
  15. tagName: `input`,
  16. attrs:{type:'text', id:'name'}
  17. },
  18. {
  19. tagName: `input`,
  20. attrs:{type:'text', id:'surname'}
  21. },
  22. ]
  23. },
  24. {
  25. tagName: `div`,
  26. subTags: [
  27. {
  28. tagName:`bottom`,
  29. attrs:{id:'ok'}, text:`OK`
  30. },
  31. {
  32. tagName:`bottom`,
  33. attrs:{id:'cancel'}, text:`Cancel`
  34. }
  35. ]
  36. }
  37. ]
  38. }
  39. body.subTags[1].subTags[1].text
  40. body.subTags[0].subTags[3].attrs.id
  41. //declarative fields
  42. let notebook = {
  43. brand: prompt (`Enter a brand`),
  44. type: prompt('Enter a type'),
  45. model: prompt('Enter a model'),
  46. ram: +prompt('Enter a ram'),
  47. size: prompt('Size'),
  48. weight: +prompt('Weight'),
  49. resolution: {
  50. width: +prompt ('Width'),
  51. height: +prompt ('Height'),
  52. },
  53. };
  54. let phone = {
  55. brand: prompt('Enter a brand'),
  56. model: prompt('Enter a model'),
  57. ram: +prompt('Enter a ram'),
  58. color: prompt('Enter a color'),
  59. };
  60. let person = {
  61. name: prompt('Enter a name'),
  62. surname: prompt('Enter a surname'),
  63. married: confirm(),
  64. };
  65. //imperative array fill
  66. let element1 = +prompt(`Введите первый елемент`);
  67. let element2 = +prompt(`Введите второй елемент`);
  68. let element3 = +prompt(`Введите третий елемент`);
  69. let element = [];
  70. element.push (element1,element2,element3);
  71. alert(element);
  72. //while confirm
  73. let cake01 = ``;
  74. while(cake01!=true) {
  75. cake01 = confirm(`Будешь кекс`)
  76. }
  77. //array fill
  78. let arr0 = [];
  79. let add = ``;
  80. while(add != null)
  81. {
  82. add = prompt(`введите даные`),
  83. arr0.push(add);
  84. }
  85. //array fill nopush
  86. let arr01 = [];
  87. let j = 0;
  88. let add1 = ``;
  89. while(add1 != null)
  90. {
  91. add1 = prompt(`введите данные`),
  92. arr01[j] = add1; ++j
  93. }
  94. //empty loop
  95. let block = ``;
  96. while(block!= prompt());
  97. //progression sum
  98. let z = 0;
  99. for(i = 1; i < 50; i+=3){
  100. z = z + i}
  101. //chess one lin
  102. let h = '';
  103. for(i = 0; i < 15; i++){
  104. if(i % 2 === 1){
  105. h = h + ' '}
  106. else {
  107. h = h + '#'}}
  108. //numbers
  109. let str = ''
  110. for(i=0;i<10;i++){
  111. str += '\n'
  112. for(p=0;p<10;p++){
  113. str+=p
  114. }
  115. }console.log(str)
  116. //chess