//while confirm { let question while(!question){ question = confirm("Putin huylo?") if(question){ break } } } //array fill { let arr = [] let question while(question = prompt()){ arr.push(question) } console.log(arr) } //array fill nopush { let arr = [] let question let i = 0 while(question = prompt()){ arr[i] = question i++ } console.log(arr) } //infinite probability { let arr = [] while(Math.random() < 0.9){ arr.push("a") if(Math.random() > 0.9){ alert(`${arr.length}`) break } } } //empty loop //Сделайте цикл с prompt, который прерывается по нажатию OK и продолжается по нажатию "Отмена" c пустым телом цикла. { let question while(prompt("Write something") == null){ question = prompt("Write something") if(question == String){ break } } } //progression sum { let result = 0 for(i=1;i<20;i+=3){ result += i } console.log(result) } //chess one line { let str ="" function symbol(lineLenght) { for(i=0;i{ for(i=0;i{ let arr=[] let obj = {} let i=0 let key,value while(confirm(`do you want create an object${i}`)){ while(key = prompt(`Write your key or click "Отмена"`)){ value = prompt("write value for key") obj[key] = value } arr.push(obj) obj={} i++ } return arr } readArrayOfObjects() } //DOM: multiply table { let table = document.createElement('table') table.border = "1" for(i=1;i<10;i++){ let tr = document.createElement('tr') table.append(tr) if(i%2===0){ tr.style.background = 'silver' } for(j=1;j<10;j++){ let td = document.createElement('td') tr.append(td) td.innerText = i * j } } document.body.append(table) } //DOM: highlight cell { let table = document.createElement('table') table.border = "1" for(i=1;i<10;i++){ let tr = document.createElement('tr') table.append(tr) if(i%2===0){ tr.style.background = 'silver' } for(j=1;j<10;j++){ let td = document.createElement('td') tr.append(td) td.innerText = i * j td.onmouseover = () =>{ td.style.backgroundColor = "red" } td.onmouseout = () => { td.style.backgroundColor= "" } } } document.body.append(table) } //DOM: Highlight cross { let table = document.createElement("table") table.border = "2" for (let i = 1; i <= 9; i++) { let tr = document.createElement("tr") table.append(tr); for (let j = 1; j < 10; j++) { let td = document.createElement("td") td.innerText = i * j tr.append(td) td.onmouseover = () => { for (let k = 0; k < 9; k++) { table.rows[i - 1].cells[k].style.backgroundColor = "lightblue" } for (let k = 0; k < 9; k++) { table.rows[k].cells[j - 1].style.backgroundColor = "lightblue" } td.style.backgroundColor = "yellow" } td.onmouseout = () => { for (let k = 0; k < 9; k++) { table.rows[i - 1].cells[k].style.backgroundColor = "" } for (let k = 0; k < 9; k++) { table.rows[k].cells[j - 1].style.backgroundColor = "" } } } } document.body.append(table) }