|
@@ -1,281 +0,0 @@
|
|
|
-// ________html tree_________
|
|
|
-var body = {
|
|
|
- tagName: "body",
|
|
|
- subTags: [
|
|
|
- {tagName: "div",
|
|
|
- subTags : [
|
|
|
- {
|
|
|
- tagName: "span",
|
|
|
- text: "Enter a data please",
|
|
|
- },
|
|
|
- {
|
|
|
- taName: "br/"
|
|
|
- },
|
|
|
- {
|
|
|
- tagName: "input",
|
|
|
- attrs: {
|
|
|
- type: "text",
|
|
|
- id: "name",
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- tagName: "input",
|
|
|
- attrs: {
|
|
|
- type: "text",
|
|
|
- id: "surname",
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {tagName: "div",
|
|
|
- subTags: [
|
|
|
- {
|
|
|
- tagName: "button",
|
|
|
- attrs: {
|
|
|
- id: "name",
|
|
|
- },
|
|
|
- text: "ok",
|
|
|
- },
|
|
|
- {
|
|
|
- tagName: "button",
|
|
|
- attrs: {
|
|
|
- id : "canel",
|
|
|
- },
|
|
|
- text: "Cancel",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
-};
|
|
|
-
|
|
|
-console.log(body.subTags[1].subTags[1].text);
|
|
|
-console.log(body.subTags[0].subTags[3].attrs.id);
|
|
|
-
|
|
|
-// ________declarative fields_________
|
|
|
-
|
|
|
-var person = {
|
|
|
- name: prompt("Имя: "),
|
|
|
- surname: prompt("Фамилия: "),
|
|
|
- married: confirm("Женатый: "),
|
|
|
-};
|
|
|
-
|
|
|
-console.log(person)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// // ________object links_________
|
|
|
-
|
|
|
-person.smartphone = {nameDevice: "Iphone 11"}, person.laptop = {nameDevice: "Lenovo ideapad"}
|
|
|
-person.smartphone.owner = person;
|
|
|
-person.laptop.owner = person;
|
|
|
-console.log(person.smartphone.owner.laptop.owner.smartphone === person.smartphone);
|
|
|
-
|
|
|
-// ________imperative array fill 3_________
|
|
|
-
|
|
|
-arr = [+prompt("input number 1"), +prompt("input number 2"), +prompt("input number 3")];
|
|
|
-console.log(arr);
|
|
|
-
|
|
|
-// // ________while confirm_________??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
|
|
-
|
|
|
-for(;;){
|
|
|
- alert("Выполняется безконечный цикл!!!");
|
|
|
- let stop1 = confirm("Прекратить выполнеие цикла?");
|
|
|
- if(stop1 === true){
|
|
|
- alert("Выполнение цикла прекращено");
|
|
|
- break;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// // ________array fill_________
|
|
|
-
|
|
|
-let array1 = [];
|
|
|
-for(let i = 0; ;){
|
|
|
- let element = prompt("Введите число или нажмите Отмена")
|
|
|
- if(element === null){
|
|
|
- alert("Выполнение цикла прекращено");
|
|
|
- break;
|
|
|
- }
|
|
|
- array1.push(element);
|
|
|
-}
|
|
|
-console.log(array1)
|
|
|
-
|
|
|
-
|
|
|
-// // ________array fill nopush_________,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.
|
|
|
-
|
|
|
-let array2 = [];
|
|
|
-
|
|
|
-for(let i = 0;;i++){
|
|
|
- let element2 = prompt("Введите число или нажмите Отмена")
|
|
|
- if(element2 === null){
|
|
|
- alert("Выполнение цикла прекращено");
|
|
|
- break;
|
|
|
- }
|
|
|
- else{
|
|
|
- array2[i] = element2;
|
|
|
- }
|
|
|
-}
|
|
|
-console.log(array2)
|
|
|
-
|
|
|
-
|
|
|
-// // ________infinite probability_________
|
|
|
- for(let i = 1; ;i++){
|
|
|
- let stopnum = Math.random()*(1.3);
|
|
|
- if(stopnum > 0.9){
|
|
|
- alert(`Выполнение цикла прекращено!\nК-во итераций = ${i}, Читсло остановки = ${stopnum}`);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-// ________empty loop_________
|
|
|
-let choice
|
|
|
-for(;choice !== null;choice = prompt("Продолжить выполнения цикла?")){
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-// // ________progression sum_________
|
|
|
-
|
|
|
-let sum = 0;
|
|
|
-let maximum = +prompt("Введите максимальное число прогрессии")
|
|
|
-for (let i = 1; i < maximum; i += 3){
|
|
|
- sum += i;
|
|
|
-}
|
|
|
-alert(`${sum}`);
|
|
|
-
|
|
|
-
|
|
|
-// // ________chess one line_________
|
|
|
-let line = "";
|
|
|
-let sizeLine = +prompt("Введите длину строки: ")
|
|
|
-for(let i = 0; i < sizeLine; i++){
|
|
|
- if(i % 2 === 1){
|
|
|
- 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';
|
|
|
-}
|
|
|
-console.log(string);
|
|
|
-
|
|
|
-
|
|
|
-// // ________chess_________
|
|
|
-
|
|
|
-let chess = '';
|
|
|
-for (let i = 0; i < 10; i++){
|
|
|
- for(let j = 0; j < 12; j++){
|
|
|
- if(i % 2 === 0){
|
|
|
- if(j % 2 === 1){
|
|
|
- chess += "#";
|
|
|
- }
|
|
|
- else{
|
|
|
- chess += ".";
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- if(j % 2 === 0){
|
|
|
- chess += "#";
|
|
|
- }
|
|
|
- else{
|
|
|
- chess += ".";
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- chess += '\n';
|
|
|
-}
|
|
|
-console.log(chess);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// // ________cubes_________
|
|
|
-let cubes = [];
|
|
|
-let n = +prompt("Ведите максимально число: ");
|
|
|
-for (let i = 0; i <= n; i++){
|
|
|
- cubes[i] = Math.pow(i, 3);
|
|
|
-}
|
|
|
-console.log(cubes)
|
|
|
-
|
|
|
-
|
|
|
-// // ________multiply table_________
|
|
|
-var multTable = [];
|
|
|
-for (var i = 1; i <= 9; i++) {
|
|
|
- multTable[i] = [];
|
|
|
- for (var j = 1; j <= 9; j++) {
|
|
|
- multTable[i][j] = i * j;
|
|
|
- }
|
|
|
-}
|
|
|
-console.log(multTable)
|
|
|
-
|
|
|
-
|
|
|
-// // ________matrix to html table_________
|
|
|
-
|
|
|
-var multTable = [];
|
|
|
-let str = "<table border = '1'>"
|
|
|
-for (var i = 1; i <= 10; i++) {
|
|
|
- str += "<tr>"
|
|
|
- multTable[i] = [];
|
|
|
- for (var j = 1; j <= 10; j++) {
|
|
|
- multTable[i][j] = i * j;
|
|
|
- str += `<td> ${multTable[i][j]} </td>`
|
|
|
- }
|
|
|
- str += "</tr>"
|
|
|
-}
|
|
|
-str += "</table>"
|
|
|
-document.write(str)
|
|
|
-
|
|
|
-// Или так
|
|
|
-
|
|
|
-// // window.onload = function() {
|
|
|
-// // var newTable = document.createElement("table");
|
|
|
-// // for (var i = 1; i <= 10; i++) {
|
|
|
-// // var newRow = newTable.insertRow(i-1)
|
|
|
-// // for (var j = 1; j <= 10; j++) {
|
|
|
-// // var newCell = newRow.insertCell(j-1);
|
|
|
-
|
|
|
-// // newCell.innerHTML = i * j;
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // document.body.appendChild(newTable)
|
|
|
-// // }
|
|
|
-
|
|
|
-// // window.onload = function() {
|
|
|
-// // var newTable = document.createElement("table");
|
|
|
-// // for (var i = 1; i <= 10; i++) {
|
|
|
-// // var newRow = newTable.insertRow(i-1)
|
|
|
-// // for (var j = 1; j <= 10; j++) {
|
|
|
-// // var newCell = newRow.insertCell(j-1);
|
|
|
-
|
|
|
-// // newCell.innerHTML = i * j;
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// // document.body.appendChild(newTable)
|
|
|
-// // }
|
|
|
-
|
|
|
-
|
|
|
-// // ________Задание на синий пояс: треугольник_________
|
|
|
-var i = 0, j = 0;
|
|
|
-
|
|
|
-var max = 6;
|
|
|
-var space = "",
|
|
|
- star = "";
|
|
|
-
|
|
|
-while (i <= max) {
|
|
|
- space = "";
|
|
|
- star = "";
|
|
|
- for (j = 0; j < max - i; j++) space += ".";
|
|
|
- for (j = 0; j < 2 * i + 1; j++) star += "#";
|
|
|
- console.log(space + star + space);
|
|
|
- i++;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|