//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', attrs: { id: 'ok' }, text: 'OK' }, { tagName: 'button', attrs: { id: 'cancel' }, text: 'Cancel' }, ] } ] } body.subTags[1].subTags[1].text body.subTags[1].subTags[1].attrs.id //declarative fields // let laptop = { // brand: prompt('Enter a brand of the laptop'), // type: prompt('Enter a type of the laptop'), // model: prompt('Enter a model of the laptop'), // ram: +prompt('Enter a ram size of the laptop'), // size: prompt('Enter a size of the laptop'), // weight: +prompt('Enter a weight of the laptop'), // resolution: { // width: +prompt('Enter a display resolution (width) of the laptop'), // height: +prompt('Enter a display resolution (height) of the laptop'), // }, // } // let phone = { // brand: prompt('Enter a brand of the phone'), // model: prompt('Enter a model of the phone'), // ram: +prompt('Enter a ram size of the phone'), // color: prompt('Enter a color of the phone'), // } // let person = { // name: prompt('Enter the person\'s name'), // surname: prompt('Enter the person\'s surname'), // married: confirm('Is this person married?'), // } //object links // person.laptop = laptop // person.smartphone = phone // laptop.owner = person // phone.owner = person //imperative array fill 3 // let array = [] // for (let i = 0; i < 3; i++) { // array[i] = prompt('?') // } //while confirm // let counter = 0 // while (!confirm('Нажмите отмена')){ // counter++ // if (counter == 5) { // alert('Еще не надоело?') // } // }; //array fill // let zoo = [] // while(true) { // let newAnimal = prompt('Введите название зверушки') // if(newAnimal == null) { // break; // } // zoo.push(newAnimal); // } //array fill nopush // let zoo = [] // let i = 0 // while(true) { // let newAnimal = prompt('Введите название зверушки') // if(newAnimal == null) { // break; // } // zoo[i] = newAnimal // i++ // } //infinite probability // let counter = 0 // while (true) { // counter++ // if (Math.random() > 0.9) { // alert(counter) // break // } // } //empty loop // while (prompt('Скинь сотку на карту плез') == null); //progression sum // let n = +prompt('До какого числа хотите считать?') // let sum = 0 // for (let i = 1; i < n; i += 3) { // sum += i; // } // alert(sum) //chess one line // let length = prompt ('Укажите длину строки пожалуйста прошу вас') // let line = ''; // for (let i = 0; i < length; i++) { // if (i % 2 == 0) { // line += ' ' // } else { // line += '#' // } // } // console.log(`"${line}"`) //numbers // let string = '' // for (let i = 0; i < 10; i++) { // for (let j = 0; j < 10; j++) { // string += j // } // string += '\n' // } //chess // let length = +prompt ('Укажите размер поля (x)') // let height = +prompt ('Укажите размер поля (y)') // let line = ''; // for (let i = 0; i < height; i++ ) { // for (let j = 0; j < length; j++) { // if (i % 2 == 0) { // if (j % 2 == 0) { // line += '.' // } else { // line += '#' // } // } else { // if (j % 2 == 0) { // line += '#' // } else { // line += '.' // } // } // } // line += '\n' // } // console.log(line) //cubes // let n = +prompt('Сколько элементов в массиве?') // let arr = []; // for (let i = 0; i < n; i++) { // arr[i] = i**3 // } //multiply table let multiplyTable = [] for (let i = 0; i <=10; i++) { multiplyTable[i] = [] for (let j = 0; j <=10; j++) { multiplyTable[i][j] = i * j } } //matrix to html table document.write('
⛧ | ') } else { document.write('' + i + ' | ') } for (let j = 1; j < multiplyTable[i].length; j++) { if (i == 0) { document.write('' + multiplyTable[1][j] + ' | ') } else { document.write('' + multiplyTable[i][j] + ' | ') } } document.write('