/* let body ={
tagName: 'body',
children: [
{tagName: 'div',
children: [{tagName: 'span',
children:["Enter a data please"]}, {tagName: 'input', attrs: {id: 'name',type:'text' }},
{tagName: 'input', attrs: {id: 'surname',type:'text' }},
{tagName: '/br'}
]},
{tagName: 'div',
children: [{tagName: 'button', attrs:{id : 'id'}},
{tagName: 'button', attrs:{id: 'cancel'}}
]}
]
}
console.log(body.children[0].children[0].children);
console.log(body.children[1].children[1].attrs.id); */
/*
*/
/* let table = {
tagName : 'table',
attrs : {
border: '1'
},
subTags: [
{
tagName: 'tr',
subTags: [{
tagName: 'td',
textInCell: '1x1'
},
{
tagName:'td',
textInCell: '1x2'
}]},
{
tagName: 'tr',
subTags: [{
tagName: 'td',
textInCell: '2x1'
},
{
tagName: 'td',
textInCell: '2x2'
}]
}
]
}
console.log(table.subTags[0].subTags[0].textInCell);
console.log(table.subTags[1].subTags[1].textInCell); */
/* let boddy = document.getElementById('body');
//multiplay table
let table = document.createElement('table')
let tbody = document.createElement('tbody')
for(let rowIndex = 1; rowIndex<10; rowIndex++){
let rows = document.createElement('tr');
for(let cellIndex = 1; cellIndex<10; cellIndex++){
let cell = document.createElement('td');
let cellText = document.createTextNode(rowIndex*cellIndex);
cell.appendChild(cellText);
rows.appendChild(cell);
}
tbody.appendChild(rows);
}
table.appendChild(tbody);
boddy.appendChild(table);
*/
/* let str = '';
for (let rowIndex = 1; rowIndex<10; rowIndex++){
str+='';
for(let cellIndex = 1; cellIndex<10; cellIndex++) {
str+=`${rowIndex*cellIndex} | `;
}
str+='
'
}
str+='
';
document.write(str); */
/* let person = {
name: prompt("Input your name", ""),
surname: prompt("Input your surname", ""),
married: confirm('You are married?'),
}
let notebook = {
brand: prompt("Input brand of Notebook", ""),
type: prompt("Input type of Notebook", ""),
model: prompt("Input model of Notebook", ""),
ram: +prompt("Input ram of Notebook", ""),
size: prompt("Input size of Notebook", ""),
weight: +prompt("Input weight of Notebook", ""),
resolution: {
width: +prompt("Input width of screen on Notebook", ""),
height: +prompt("Input height of screen on Notebook", ""),
},
};
let phone = {
brand: prompt("Input brand of Phone", ""),
model: prompt("Input model of Phone", ""),
ram: +prompt("Input ram of Phone", ""),
color: prompt("Input color of Phone", ""),
};
person.notebook = notebook;
notebook.owner = person;
person.phone = phone;
phone.owner = person;
console.log(person.phone.owner.notebook.owner.phone == person.phone); */
/* let eternalLoop = confirm("press no pls")
while(!eternalLoop){
eternalLoop = confirm("press no pls");
} */
/* infinite probability */
/* let i = 0;
for(;;) {
i++;
if(Math.random() > 0.9){
alert(`count of iterations ${i}`);
break;
}
} */
/* empty loop */
/* while(null == prompt('press no to continue', "")){
} */
/* cubes */
/*
function promotionToHigherValue(arr,f) {
let result = [];
for(let item of arr) {
result.push(f(item));
}
console.log(result);
}
promotionToHigherValue([1,2,3,4,5], x => x**3); */
/* progression sum */
/* let sum = 0;
let lengthOfProgression = +prompt("input length of prgression", '');
for (let i = 1; i<=lengthOfProgression; i+=3){
sum=sum + i;
}
alert(sum); */
/* how to write christmas tree */
/*
const buildTree = tier => {
// more interesting solution but for me hard understand to make it by myself
let s = Array(tier - 1).join(' ');
for (s = s + '#' + s; tier--; console.log(s), s = s.replace(/\s(#+)\s/, '#$1#'));
}
buildTree(15); /* from internet solution and that so hard to understand how that magic works*/
/* */
/* function pyramid(n) {
for(let i = 1; i <= n; i++){
let s = "";
for(let j = 1; j<=(2*n -1); j++){
(j>= n+1-i && j<= n-1+i) ? s+="#" : s+=".";
}
console.log(s);
}
}
pyramid(+prompt("input number of tree rows", '')); */