"use strict"; function htmlTree() { let body = { tagName: 'body', subTags: [{ tagName: 'div', subTags: [{ tagName: "span", text: "Enter a data please:", }, { 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[1].subTags[1].text); console.log(body.subTags[0].subTags[2].attrs.id); } // htmlTree() function declarativeFields() { let notebook = { brand: prompt("Enter a brand your notebook", "HP"), type: prompt("Enter a type your notebook", "440 G4"), model: prompt("Enter a model your notebook", "Y7Z75EA"), ram: +prompt("Enter a ram your notebook", "4"), size: prompt("Enter a size your notebook", "14"), weight: +prompt("Enter a weight your notebook", "1.8,"), resolution: { width: +prompt("Enter a screen width in px", "1920"), height: +prompt("Enter a screen height in px", "1080"), }, owner: prompt("Enter the owner of the notebook", "Alex"), }; let phone = { brand: prompt("Enter a brand your phone", "meizu"), model: prompt("Enter a model your phone", "m2"), ram: +prompt("Enter a ram your phone", "2"), color: prompt("Enter a color your phone", "black"), owner: prompt("Enter the owner of the phone", "Kate"), }; let person = { name: prompt("Enter a your name", "Donald"), surname: prompt("Enter a your surname", "Trump"), married: confirm("Are you married?"), smartphone: confirm("Do you have a smartphone?"), laptop: confirm("Do you have a laptop?"), } person.smartphone = notebook; notebook.owner = person; person.laptop = phone; phone.owner = person; console.log(person.smartphone.owner.laptop.owner.smartphone == person.smartphone) } // declarativeFields() function imperativeArray() { let arr = []; for (let i = 0; i < 3; i++) { let userAnswer = prompt("Напиши 3 своих любимых сериала", ""); arr.push(userAnswer); } console.log(arr); } // imperativeArray() function whileConfirm() { while (confirm("Hi") == false) { if (confirm("Hi") !== false) { break; } } } // whileConfirm() function arrayFill() { let arr = []; while (true) { let userAnswer = prompt("Перечисли свои любимые фильмы", ""); if (isNaN(userAnswer)) { arr.push(userAnswer); }; if (userAnswer == null) { break; } } console.log(arr); } // arrayFill() function arrayFillNopush() { let arr = []; let i = 0; while (true) { let userAnswer = prompt("Перечисли свои любимые фильмы", ""); if (isNaN(userAnswer)) { arr[i] = userAnswer; } if (userAnswer == null) { break; } i++; } console.log(arr); } // arrayFillNopush() function infiniteProbability() { let i = 0; let randomNumber = 0; while (true) { randomNumber = Math.random(i); if (randomNumber > 0.9) { break; } i++; console.log(randomNumber); } alert(i); } // infiniteProbability() function emptyLoop() { while (prompt() === null) {} } // emptyLoop() function progressionSum() { let userNumber = prompt("Введите число", ""); let progressionSum = 0; for (let i = 0; i < userNumber; i++) { progressionSum = progressionSum + (1 + (i * 3)); } console.log(progressionSum); } // progressionSum() function chessOneLine() { let str = ""; for (let i = 0; i < 5; i++) { str += "# "; } console.log(str); } // chessOneLine() function numbers() { let str = ""; for (let a = 0; a < 10; a++) { for (let i = 0; i < 10; i++) { str += i; } str += "\n"; } console.log(str); } // numbers() function chess() { let str = ""; for (let i = 0; i < 10; i++) { for (let x = 0; x < 10; x++) { if ((x + i) % 2 == 0) str += ". "; else str += "# "; } str += "\n"; } console.log(str); } // chess() function cubes() { let arr = [0, 1, 2, 5, 10]; let num = 0; let arrMode = []; for (let key of arr) { let cube = num * num * num; arrMode.push(cube); num++; } console.log(arrMode) } // cubes() function multiplyTable() { let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arrMode = []; for (let keyN of arr) { arrMode[keyN] = []; for (let keyM of arr) { arrMode[keyN][keyM] = (keyN * keyM); } } console.log(arrMode[7][2]) } // multiplyTable() function matrix() { let tab = document.getElementById("table"); let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let arrMode = []; let html = "
${keyN} | ${keyM} | ${keyN * keyM} |