|
@@ -0,0 +1,356 @@
|
|
|
+//Task html tree
|
|
|
+// let body = {
|
|
|
+// tagName: 'body',
|
|
|
+// subTages: [
|
|
|
+// {
|
|
|
+// tagName: 'div',
|
|
|
+// subTages: [
|
|
|
+// {
|
|
|
+// 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',
|
|
|
+// subTages: [
|
|
|
+// {tagName: 'button',
|
|
|
+// attrs: {
|
|
|
+// id:'ok',
|
|
|
+// },
|
|
|
+// text: 'OK',
|
|
|
+// },
|
|
|
+// {
|
|
|
+// tagName: 'button',
|
|
|
+// attrs: {
|
|
|
+// id: 'cancel',
|
|
|
+// },
|
|
|
+// text: 'Cancel',
|
|
|
+// }
|
|
|
+// ]
|
|
|
+// }
|
|
|
+// ]
|
|
|
+// }
|
|
|
+// console.log(body.subTages[1].subTages[1].text)
|
|
|
+
|
|
|
+// console.log(body.subTages[1].subTages[1].attrs['id'])
|
|
|
+
|
|
|
+//Task declarative fields
|
|
|
+// var notebook = {
|
|
|
+// brand: prompt('Enter notebook-brand'),
|
|
|
+// type: prompt('Enter notebook-type'),
|
|
|
+// model: prompt('Enter notebook-model'),
|
|
|
+// ram: prompt('Enter notebook-ram'),
|
|
|
+// size: prompt('Enter notebook-size'),
|
|
|
+// weight: prompt('Enter notebook-weight'),
|
|
|
+// resolution: {
|
|
|
+// width: prompt('Enter notebook-resolution-width'),
|
|
|
+// height: prompt('Enter notebook-resolution-height'),
|
|
|
+// },
|
|
|
+// };
|
|
|
+
|
|
|
+// var phone = {
|
|
|
+// brand: prompt('Enter phone-brand'),
|
|
|
+// model: prompt('Enter phone-model'),
|
|
|
+// ram: prompt('Enter phone-ram'),
|
|
|
+// color: prompt('Enter phone-color'),
|
|
|
+// };
|
|
|
+
|
|
|
+// var person = {
|
|
|
+// name: prompt('Enter your name'),
|
|
|
+// surname: prompt('Enter ypur surname'),
|
|
|
+// married: confirm('Are you married?'),
|
|
|
+// };
|
|
|
+
|
|
|
+
|
|
|
+//Task object links
|
|
|
+// var notebook = {
|
|
|
+// brand: "HP",
|
|
|
+// type: "440 G4",
|
|
|
+// model: "Y7Z75EA",
|
|
|
+// ram: 4,
|
|
|
+// size: "14",
|
|
|
+// weight: 1.8,
|
|
|
+// resolution: {
|
|
|
+// width: 1920,
|
|
|
+// height: 1080,
|
|
|
+// },
|
|
|
+// };
|
|
|
+
|
|
|
+// var phone = {
|
|
|
+// brand: "meizu",
|
|
|
+// model: "m2",
|
|
|
+// ram: 2,
|
|
|
+// color: "black",
|
|
|
+// };
|
|
|
+
|
|
|
+// var person = {
|
|
|
+// name: "Donald",
|
|
|
+// surname: "Trump",
|
|
|
+// married: true,
|
|
|
+// };
|
|
|
+
|
|
|
+
|
|
|
+// person.smartphone = phone;
|
|
|
+// person.laptop = notebook;
|
|
|
+// notebook.owner= person;
|
|
|
+// phone.owner = person;
|
|
|
+
|
|
|
+// console.log(person.smartphone.owner.laptop.owner.smartphone == person.smartphone);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//Task imperative array fill 3
|
|
|
+// arr = [];
|
|
|
+// arr[0] = prompt('Enter 1 index');
|
|
|
+// arr[1] = prompt('Enter 2 index');
|
|
|
+// arr[2] = prompt('Enter 3 index');
|
|
|
+// console.log(arr);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//Task while confirm
|
|
|
+// for (let i = 0; !confirm(''); i++) {
|
|
|
+// confirm('');
|
|
|
+// };
|
|
|
+
|
|
|
+
|
|
|
+//Task array fill
|
|
|
+// arr = [];
|
|
|
+// let index = prompt('');
|
|
|
+// while (index) {
|
|
|
+// arr.push(index);
|
|
|
+// index = prompt('');
|
|
|
+// };
|
|
|
+// console.log(arr);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//Task array fill nopush
|
|
|
+// arr = [];
|
|
|
+// let index = prompt('');
|
|
|
+// while (index) {
|
|
|
+// arr[arr.length] = index;
|
|
|
+// index = prompt('');
|
|
|
+// };
|
|
|
+// console.log(arr);
|
|
|
+
|
|
|
+
|
|
|
+//Task infinite probability
|
|
|
+// debugger;
|
|
|
+// let countIteration = 0;
|
|
|
+// while (true) {
|
|
|
+// countIteration++;
|
|
|
+// let z = Math.random();
|
|
|
+// if ( z > 0.9) {
|
|
|
+// break;
|
|
|
+// };
|
|
|
+// };
|
|
|
+// console.log(countIteration);
|
|
|
+
|
|
|
+
|
|
|
+//Task empty loop
|
|
|
+// while (prompt('') == null) {
|
|
|
+
|
|
|
+// };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//Task progression sum
|
|
|
+//Подсчитать сумму арифметической прогрессии от 1 до N c шагом 3 (1,4,7....) используя цикл for.
|
|
|
+// let sum = 1;
|
|
|
+// for (let i = 0; i<10; i++) {
|
|
|
+// sum += 3;
|
|
|
+// console.log(sum);
|
|
|
+// };
|
|
|
+// console.log(sum);
|
|
|
+
|
|
|
+
|
|
|
+//Task chess one line
|
|
|
+// let str = '';
|
|
|
+// let lengthStr = prompt('enter lengthStr');
|
|
|
+// for (let i = 1; i<=lengthStr; i++) {
|
|
|
+// str = str + '#' + ' ';
|
|
|
+// };
|
|
|
+// console.log(str);
|
|
|
+
|
|
|
+
|
|
|
+//Task numbers
|
|
|
+// let str ="";
|
|
|
+// let n = '\n';
|
|
|
+// for (let i = 0; i < 10; i++) {
|
|
|
+// for (let q = 0; q < 10; q++) {
|
|
|
+// str += q;
|
|
|
+// }
|
|
|
+// str += n;
|
|
|
+// };
|
|
|
+// console.log(str)
|
|
|
+
|
|
|
+
|
|
|
+//Task chess
|
|
|
+// let str ="";
|
|
|
+// let n = '\n';
|
|
|
+// let point = '.';
|
|
|
+// let shtrih = '#';
|
|
|
+// let widthChess = 10;
|
|
|
+// let heightChess = 10;
|
|
|
+
|
|
|
+// for (let i = 1; i <= heightChess; i++) {
|
|
|
+
|
|
|
+// if (i % 2 == 00) {
|
|
|
+// point = '#';
|
|
|
+// shtrih = '.';
|
|
|
+// };
|
|
|
+// if (i % 2 !==0) {
|
|
|
+// point = '.';
|
|
|
+// shtrih = '#';
|
|
|
+// };
|
|
|
+
|
|
|
+// for (let q = 1; q <= widthChess; q++) {
|
|
|
+// str += point + shtrih;
|
|
|
+// };
|
|
|
+// str += n;
|
|
|
+// };
|
|
|
+// console.log(str)
|
|
|
+
|
|
|
+
|
|
|
+//Task cubes
|
|
|
+//debugger;
|
|
|
+// let arr = [];
|
|
|
+
|
|
|
+// for (let i = 0; i < 10; i++) {
|
|
|
+// arr[i] = i**3;
|
|
|
+// };
|
|
|
+// console.log(arr);
|
|
|
+
|
|
|
+
|
|
|
+//Task multiply table
|
|
|
+// let arr = [];
|
|
|
+
|
|
|
+// for (let i = 0; i < 10; i ++) {
|
|
|
+// arr[i] = [];
|
|
|
+// for (let q = 0; q < 10; q ++ ) {
|
|
|
+// arr[i][q] = i * q;
|
|
|
+// };
|
|
|
+// };
|
|
|
+
|
|
|
+// console.log(arr);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//Task matrix to html table
|
|
|
+//const table = '<table>';
|
|
|
+// const tr = '<tr>';
|
|
|
+// const th = '<th>';
|
|
|
+// let str = '<table>';
|
|
|
+
|
|
|
+// for (let i = 0; i < 10; i ++) {
|
|
|
+// str += tr;
|
|
|
+// for (let q = 0; q < 10; q ++ ) {
|
|
|
+// let multiplication = `${i} x ${q} = ${i * q}`;
|
|
|
+// str += th + multiplication + '</th>';
|
|
|
+// };
|
|
|
+// str += '</tr>';
|
|
|
+// };
|
|
|
+
|
|
|
+// document.write(str);
|
|
|
+
|
|
|
+
|
|
|
+// Task Задание на синий пояс: Треугольник
|
|
|
+// let str ="";
|
|
|
+// let n = '\n';
|
|
|
+// let point = '.';
|
|
|
+// let shtrih = '#';
|
|
|
+// let widthChess = 10;
|
|
|
+// let heightChess = 5;
|
|
|
+
|
|
|
+// for (let i = 0; i <= heightChess; i++) {
|
|
|
+
|
|
|
+// let center = Math.floor(widthChess/2); console.log(center);
|
|
|
+
|
|
|
+// for (let q = 0; q <= widthChess; q++) {
|
|
|
+
|
|
|
+// if (q < (center - i)) {
|
|
|
+// str += point;
|
|
|
+// };
|
|
|
+// if (((center - i) <= q) && (q <=(center + i))) {
|
|
|
+// str += shtrih;
|
|
|
+// };
|
|
|
+// if (q > (center + i)) {
|
|
|
+// str += point;
|
|
|
+// };
|
|
|
+// };
|
|
|
+
|
|
|
+// str += n;
|
|
|
+// };
|
|
|
+// console.log(str);
|
|
|
+
|
|
|
+
|
|
|
+//Task Задание на черный пояс: Электронная гадалка
|
|
|
+
|
|
|
+let history = [1, 1, 1, 1];
|
|
|
+let predictArray = [];
|
|
|
+
|
|
|
+for( let i = 0; i < 2; i++) {
|
|
|
+ predictArray[i] = [];
|
|
|
+ for (let q = 0; q < 2; q++) {
|
|
|
+ predictArray[i][q] = [];
|
|
|
+ for (let w = 0; w < 2; w++) {
|
|
|
+ predictArray[i][q][w] = [];
|
|
|
+ for (let r = 0; r < 2; r++) {
|
|
|
+ predictArray[i][q][w][r] = -1;
|
|
|
+ };
|
|
|
+ };
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+let numberSoothsayer = -1;
|
|
|
+let numberUse = 1;
|
|
|
+for (let i = 0; numberUse !== null; i++) {
|
|
|
+ numberUse = prompt('Enter the number 1 or 0');
|
|
|
+ numberSoothsayer = predictArray[history[0]][history[1]][history[2]][history[3]];
|
|
|
+ predictArray[history[0]][history[1]][history[2]][history[3]] = numberUse;
|
|
|
+ history.shift();
|
|
|
+ history.push(numberUse);
|
|
|
+ let predict = Math.round( Math.random() );
|
|
|
+
|
|
|
+ if (numberSoothsayer == -1) {
|
|
|
+ console.log(predict);
|
|
|
+
|
|
|
+ if (numberUse == predict) {
|
|
|
+ alert('you did not guess right');
|
|
|
+ };
|
|
|
+ if ((numberUse != predict) && (numberUse !== null)) {
|
|
|
+ alert('you guessed right');
|
|
|
+ };
|
|
|
+ if (numberUse === null) {
|
|
|
+ alert('goodbye');
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ if (numberSoothsayer != -1) {
|
|
|
+
|
|
|
+ if (numberSoothsayer == numberUse) {
|
|
|
+ alert('you did not guess right');
|
|
|
+ };
|
|
|
+ if ((numberSoothsayer != numberUse) && (numberUse !== null)) {
|
|
|
+ alert('you guessed right');
|
|
|
+ };
|
|
|
+ };
|
|
|
+};
|
|
|
+
|