//html tree let body = { tagName: "body", subTags: [ { tagName: "div", subTags: [ { tagName: 'span', text: 'Enter a data please:' }, { tagName: 'br' }, { tagName: 'input', attr: { type: 'text', id: 'name' } }, { tagName: 'input', attr: { type: 'text', id: 'surname' } }, ] }, { tagName: 'div', subTags: [ { tagName: 'button', text: 'ok', attr: { id:'ok' } }, { tagName: 'button', text: 'Cancel', attr: { id: 'cancel' } } ] } ] } body.subTags[1].subTags[1].text body.subTags[0].subTags[3].attr.id //declarative fields var notebook = { brand: prompt('Enter brand'), type: prompt('Enter type'), model: prompt('Enter model'), ram: prompt('Enter ram'), size: prompt('Enter size'), weight: prompt('Enter weight'), resolution: { width: prompt('Enter width'), height: prompt('Enter height'), }, }; var phone = { brand: prompt('What is brand?'), model: prompt('What is model?'), ram: +prompt('Enter you ram?'), color: prompt('What is color?'), }; //object links var person = { name: prompt('What is you name?'), surname: prompt("What is you surname?"), married: confirm('Are you married?'), } person.phone = phone person.notebook = notebook phone.owner = person notebook.owner = person //imperative array fill 3 let th = [] th[1] = prompt(); th[2] = prompt(); th[0] = prompt() //while confirm let qw = ""; while (qw !== true) { qw = confirm('?') } //array fill let mass = []; let qu = "" while ( (qu = prompt('Чего д0бавить?')) !== null) { mass.push(qu) } //array fill nopush let mass1 = [], i=0 ; let qu1 = "" while ( (qu1 = prompt('Чего д0бавить?')) != null) { mass1[i++] = qu1 } //infinite probability let numb = 0 while ( Math.random() < 0.9) { numb += 1 } alert(numb) //empty loop let a = '' while (a != prompt()); //progression sum let aa = 0 for (i = 1; i < 100; i += 3){ aa = aa + i } //chess one line let q = "" for (i = 0; i < 15; i++){ if (i % 2 === 1) { q = q + " " } else { q = q + "#" } } //numbers /*let w = "" for (let i = 0; i < 10; i++){ w = w + "0123456789\n" } console.log(w) */ str = "" for (let i = 0; i < 10; i++){ str = str + '\n' for (let j = 0; j < 10; j++){ str = str + j } } console.log(str) //chess let chess = "" for (let i = 0; i < 6; i++) { chess += '\n' for (let j = 0; j < 6; j++) { if (i % 2 === 1) { chess += ".#" } else { chess += "#." } } } alert(chess) // cubes let mass11 = [] for (let i = 0; i < 15; i++){ mass11.push(i ** 3) } console.log(mass11[i]) //multiply table let mas = [] for (let i = 0; i < 10; i++){ mas[i] = [] for (let j = 0; j < 10; j++){ mas[i][j] = [j*i] ; //<============ или ============> mas[i].push(i*j) } } //matrix to html table тут страшные и непонятные вещи происходили , короче , как-то склепал document.write( "") let mas = [] for (let i = 1; i < 10; i++){ mas[i] = [] document.write("") for (let j = 1; j < 10; j++){ document.write( ` `) } document.write("") } document.write("
${mas[i][j] = [j * i]}
") //Задание на синий пояс: Треугольник let n = 6; for (let i = 1; i <= n; i++) { let str = ''; for (j = 1; j <= 2 * n - 1; j++) { if (j >= n - (i - 1) && j <= n + (i - 1)) { str += '#'; } else { str += '.'; } } console.log(str); }