123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- // html tree
- let body = {
- tagName: "body",
- subTags: [
- {tagName: 'div',
- subTags:[
- {tagName:'br'},
- {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'}}
- ]}
- ]
- }
- body.subTags[1].subTags[1].text
- body.subTags[0].subTags[3].attrs.id
- // declarative fields
- let notebook = {
- brand: prompt('Enter brand'),
- type: prompt('Enter type'),
- model: prompt('Enter model'),
- ram: +prompt('Enter ram'),
- size: prompt('Size'),
- weight: +prompt('Weight'),
- resolution: {
- width: +prompt ('Width'),
- height: +prompt ('Height'),
- },
- };
- let phone = {
- brand: prompt('Enter brand'),
- model: prompt('Enter model'),
- ram: +prompt('Enter ram'),
- color: prompt('Enter color'),
- };
- let person = {
- name: prompt('Enter a name'),
- surname: prompt('Enter a surname'),
- married: confirm(),
- }
- // object links
- let person1 = {
- name:prompt('Enter a name'),
- smartphone:{ owner:person1},
- laptop:{ owner:person1}
- }
- // imperative array fill 3
- let array = [];
- array[0] = +prompt();
- array[1] = +prompt();
- array[2] = +prompt();
- // while confirm
- let qvestion = '';
- while(qvestion != true){
- qvestion = confirm('are you batman?')}
- // array fill
- let array1 = [];
- let filling = '';
- while(filling != null){
- filling = prompt('введите число'),
- array1.push(filling);
- }
- // array fill nopush\
- let array2 = [];
- let i = 0;
- let filling1 = '';
- while(filling1 != null){
- filling1 = prompt('введите число')
- array2[i] = filling1;
- i++
- }
- // infinite probability:
- // через for
- for(i = 0,b=1;i<0.9;b++){
- i = Math.random()};
- alert(`Прошло ${b} итерации`)
- // через while
- let b = 0;
- let a = 0;
- while(b<0.9){
- b = Math.random()
- a++}
- alert(`${b} iteration`)
- // empty loop
- let value = '';
- while(value != prompt());
- // progression sum
- let sum = 0;
- for(i = 1; i < 50; i+=3){
- sum = sum + i}
- console.log(sum);
-
- // chess one line
- let c = '';
- for(y = 0;y < 16;y++){
- if(y % 2 === 1){
- c = c + '#'}
- else {
- c = c + '.'}}
- // numbers
- let str = ''
- for(i=0;i<10;i++){
- str += '\n'
- for(j=0;j<10;j++){
- str+=j
- }
- }console.log(str)
- // chess
- let strn = ''
- for(f = 0;f<12;f++){
- strn += '\n'
- for(y = 0;y < 12;y++){
- if(y % 2 === 1){
- strn += '#'}
- else {
- strn += '.'}}}
- // cubes(?????????)<
- // multiply table
- debugger
- let result = '\n';
- for (let f = 1;f < 11; f++){
- for(let j = 1; j < 11; j++){
- result += [f*j] + ' ';
- }
- result += '\n'
- }
- console.log(result)
- // matrix to html table(????????)
- // не понял с этого задания>
|