// html tree/////////////////////////////////////////////////// let body = { tagName: 'body', subTags: [ { tagName: 'div', subTags: [ { tagName: "span", text: "Enter a data please:", }, { tagName: "br", }, { tagName: "input", attrs: { type: 'text', id: 'name', }, }, { tagName: "input", attrs: { type: 'text', id: 'surname', }, } ] }, { tagName: 'div', subTags: [ { tagName: "button", text: "OK", attrs: { id: 'ok' }, }, { tagName: "button", text: "Cancel", attrs: { id: 'cancel' }, }, ] } ] } console.log(body.subTags[0].subTags[3].attrs.id) console.log(body.subTags[1].subTags[1].text) //declarative fields/////////////////////////////////////////// // var notebook = { // brand: prompt("enter brand name"), // type: prompt("enter type"), // model: prompt("enter model name"), // ram: +prompt("enter ram"), // size: +prompt("enter size"), // weight: +prompt("enter weight"), // resolution: { // width: +prompt("enter width"), // height: +prompt("enter height"), // }, // }; // var notebook = "enter" // var arr3 = [prompt(notebook + ' brand'), prompt(notebook + ' type'), prompt(notebook + ' model'), +prompt(notebook + ' ram'), +prompt(notebook + ' size'), +prompt(notebook + ' weight'), + prompt(notebook + ' width'), +prompt(notebook + ' height')]; // var phone = { // brand: prompt("enter brand name"), // model: prompt("enter model name"), // ram: +prompt("enter ram"), // color: prompt("enter color"), // }; // var phone = "enter" // var arr2 = [prompt(phone + ' brand'), prompt(phone + ' model'), +prompt(phone + ' ram'), prompt(phone + ' color')]; // var person = { // name: prompt("Enter a name"), // surname: prompt("Enter a surname"), // married: confirm("married?"), // }; // var person = "enter" // var arr1 = [prompt(person + ' name'), prompt(person + ' surname'), confirm("married?")]; //object links///////////////////////////////////////////////// // var person = { // smartphone: { // owner: person, // }, // laptop: { // owner: person, // } // }; //imperative array fill 3////////////////////////////////////// // let arr = []; // arr[0] = prompt("enter"); // arr[1] = prompt("enter"); // arr[2] = prompt("enter"); //while confirm//////////////////////////////////////////////// // let new1; // while (!new1) { // new1 = confirm("ok?"); // if (new1) { // break; // } // } //array fill////////////////////////////////////////////////// // let arr1 = [] // let box; // while (box !== null) { // box = prompt("ok?"); // arr1.push(box) // if (box === null) { // break; // } // } // array fill nopush////////////////////////////////////////// // let arr1 = [] // i = 0; // let box; // while (box !== null) { // box = prompt("ok?"); // arr1[i] = box; // i++ // if (box === null) { // break; // } // } // infinite probability////////////////////////////////////// // let x = 0; // let i = 0; // while (x < 0.9) { // x = Math.random() // i++ // alert(`количество итераций = ${i}`) // if (x > 0.9) { // break; // } // } ///////////////////////////////////////////////////////////// // let x = 0; // let i = 0; // for (let x = 0; x < 0.9; i++) { // x = Math.random() // } // alert(`количество итераций = ${i}`) // empty loop//////////////////////////////////////////////// // while(prompt() ===null); //////////////////////////////// // let box; // while (box !== "") { // box = prompt("enter") // if (box === "") { // break // } // } // progression sum////////////////////////////////////////// // let number = +prompt("last number"); // let sum = 0; // for (let b = 1; b < number; b += 3) { // console.log(b) // sum += b // } // alert(`${sum}`) // chess one line/////////////////////////////////////////// // let i = ' #'; // let str = ""; // for (j = 0; j < 10; j++) { // str += i; // } // console.log(str) // let str = ""; // for (a = 0; a < 10; a++) { // if (a % 2 === 0) str += " "; // else str += "#"; // } // console.log(str); // numbers/////////////////////////////////////////////////// // let str = ""; // for (a = 0; a < 10; a++) { // str += "0123456789\n"; // } // console.log(str); // let str = ""; // for (let i = 0; i < 10; i++) { // str += "\n"; // for (j = 0; j < 10; j++) { // str += j; // } // } // console.log(str); // chess///////////////////////////////////////////////////// // let str = ""; // for (let i = 0; i < 7; i++) { // str += "\n"; // for (a = 0; a < 7; a++) { // if ((a + i) % 2 === 0) str += "."; // else str += "#"; // } // } // console.log(str); // cubes//////////////////////////////////////////////////// // let arr1 = [] // for (i = 0; i < 20; i++) { // arr1.push(Math.pow(i, 3)); // } // console.log(arr1); // multiply table/////////////////////////////////////////// // let arr = []; // for (let a = 1; a <= 10; a++) { // arr[a] = []; // for (let b = 1; b <= 10; b++) { // arr[a][b] = [a * b]; // } // } // alert(arr[5][6]); // alert(arr[7][2]); // matrix to html table//////////////////////////////////// // let str = ''; // for (let a = 1; a <= 10; a++) { // str += ''; // for (let b = 1; b <= 10; b++) { // str += ``; // } // str += ''; // } // str += '
${arr[a][b]}
'; // console.log(str) // document.write(str); // Задание на синий пояс: Треугольник////////////////////// // let dotCount = 5; // let hashCount = 1; // for (let a = 1; a <= 6; a++) { // let line = '.'.repeat(dotCount) + '#'.repeat(hashCount) + // '.'.repeat(dotCount) + '\n' // dotCount = dotCount - 1; // hashCount = hashCount + 2; // console.log(line) // }