//Сама таблица Пифагора, такая же как и в домашке раньше let multiplyTable = [] for (let i = 0; i <=10; i++) { multiplyTable[i] = [] for (let j = 0; j <=10; j++) { multiplyTable[i][j] = i * j } } let tableContainer = document.querySelector('.multipleTable') let table = document.createElement('table') table.border = "1" for (let i = 0; i < multiplyTable.length; i++) { let row = document.createElement('tr') if (i == 0) { let cell = document.createElement ('td') cell.innerHTML = '⛧' row.appendChild(cell) } else { let cell = document.createElement('td') cell.innerText = i row.appendChild(cell) } for (let j = 1; j < multiplyTable[i].length; j++) { if (i == 0) { let cell = document.createElement('td') cell.innerText = multiplyTable[1][j] row.appendChild(cell) } else { let cell = document.createElement('td') cell.innerText = multiplyTable[i][j] row.appendChild(cell) } } table.appendChild(row) } tableContainer.appendChild(table) //подсветка строки и столбца с замыканиями let cells = document.querySelectorAll('td'); let rows = document.querySelectorAll('tr'); function highlightRow (tr) { let row = tr.children; function highlightCell (td, tdCount) { td.onmouseover = function () { for (let column of rows) { column.children[tdCount].style.backgroundColor = '#bcf' column.children[tdCount].style.color = '#fff' } for (let rowCell of row) { rowCell.style.backgroundColor = '#bcf' rowCell.style.color = '#fff' } td.style.backgroundColor = '#6dd' td.style.color = '#fff' } td.onmouseout = function () { for (let column of rows) { column.children[tdCount].style.backgroundColor = '' column.children[tdCount].style.color = '' } for (let rowCell of row) { rowCell.style.backgroundColor = '' rowCell.style.color = '' } td.style.backgroundColor = '' td.style.color = '' } } return highlightCell; } for (let row of rows) { let highlightCell = highlightRow(row); let tdCounter = 0; for (let cell of row.children) { highlightCell(cell, tdCounter); tdCounter++ } } //makeProfileTimer function makeProfileTimer () { let startTime = performance.now() function innerTimer () { let endTime = performance.now() let workTime = endTime - startTime; return workTime; } return innerTimer; } //makeSaver function makeSaver (func) { let result; function returnResult () { if (!result) { result = func() } return result; } return returnResult; } //Final Countdown function countdown (numb) { let counter = numb; let countdown = setTimeout(function showCountdown () { if (counter < 1) { console.log('Поехали!') return; } console.log(counter) counter-- countdown = setTimeout(showCountdown, 1000) }, 1000) } //MyBind function myBind(functionToBind, context, args) { function boundFunction (...newArgs) { let commonArgs = [] let functionResult let counter = 0 for (let argument of args) { if (argument === undefined) { commonArgs.push(newArgs[counter]) counter++ } else { commonArgs.push(argument) } } if (context) { context.key = functionToBind functionResult = context.key(...commonArgs) delete context.key } else { functionResult = functionToBind(...commonArgs) } return functionResult } return boundFunction }