123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- /* 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); */
- /*
- <table border='1'>
- <tr>
- <td>
- 1x1
- </td>
- <td>
- 1x2
- </td>
- </tr>
- <tr>
- <td>
- 2x1
- </td>
- <td>
- 2x2
- </td>
- </tr>
- </table>
- */
- /* 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 = '<table>';
- for (let rowIndex = 1; rowIndex<10; rowIndex++){
- str+='<tr>';
- for(let cellIndex = 1; cellIndex<10; cellIndex++) {
- str+=`<td>${rowIndex*cellIndex}</td>`;
- }
- str+='</tr>'
- }
- str+='</table>';
- 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", '')); */
-
-
|