|
@@ -0,0 +1,258 @@
|
|
|
+// 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: prompt("enter smartphone owner"),
|
|
|
+// },
|
|
|
+// laptop: {
|
|
|
+// owner: prompt("enter laptop owner"),
|
|
|
+// }
|
|
|
+// };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//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;
|
|
|
+// do {
|
|
|
+// box = prompt("ok?");
|
|
|
+// arr1.push(box)
|
|
|
+// }
|
|
|
+// while (box !== null)
|
|
|
+
|
|
|
+
|
|
|
+// array fill nopush//////////////////////////////////////////
|
|
|
+// let arr1 = []
|
|
|
+// i = 0;
|
|
|
+// let box;
|
|
|
+// do {
|
|
|
+// box = prompt("ok?");
|
|
|
+// arr1[i] = box;
|
|
|
+// i++
|
|
|
+// }
|
|
|
+// while (box !== null)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// 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////////////////////////////////////////////////
|
|
|
+// let box;
|
|
|
+// do {
|
|
|
+// box = prompt("ok?");
|
|
|
+// }
|
|
|
+// while (box !== "")
|
|
|
+
|
|
|
+
|
|
|
+// 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 < 5; i++) {
|
|
|
+// str += "\n";
|
|
|
+// for (a = 0; a < 12; a++) {
|
|
|
+// if (a % 2 === 0) str += ".";
|
|
|
+// else str += "#";
|
|
|
+// }
|
|
|
+// str += "\n";
|
|
|
+// for (a = 0; a < 12; a++) {
|
|
|
+// if (a % 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////////////////////////////////////
|