123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- </head>
- <body>
- <script>
- //------html tree
- /*let body={
- tagName:'body',
- attrs:{},
- children:[
- {
- tagName:'div',
- children:[
- {
- tagName:'span',
- children:[
- 'Enter a data please'
- ]
- },
- {
- tagName:'input',
- attrs:{
- type:'text',
- id:'name'
- }
- },
- {
- tagName:'input',
- attrs:{
- type:'text',
- id:'surname'
- }
- }
- ]
- },
- {
- tagName:'div',
- children:[
- {
- tagName:'button',
- attrs:{
- id:'ok'
- },
- children:['OK']
- },
- {
- tagName:'button',
- attrs:{
- id:'cancel'
- },
- children:['Cancel']
- }
- ]
- }
- ]
- }
- console.log(body.children[0].children[2].attrs.id);*/
- //------declarative fields
- /*let school={
- clasuxa:{
- name:prompt('Name of Your classuxa',''),
- smartphon:{
- owner:school,
- telephon:+prompt('telefon classuxi','')
- },
- laptop:prompt('','')
- },
- directrisa:prompt('Name of Your directrisa',''),
- numOfSchool: +prompt('Number of your school','')
- };
- console.log(JSON.stringify(students,null,2));
- */
- //------object links
- /*let person={
- name:'Kiril',
- surname:'Petrovich'
- };
- person.gajeti={
- smarthon:'38073456748',
- laptop:'Apple',
- owner:person
- }
- console.log(person.gajeti.owner.gajeti);*/
- //------imperative array fill 3
- /*let arr=[];
- arr[0]=prompt('','');
- arr[1]=+prompt('','');
- arr[2]=+prompt('','');
- console.log(arr);*/
- //------while confirm
- /*let num=false;
- while(num==false){
- num=confirm(''); //постоянный confirm пока не ОК
- }*/
- //-------array fill
- /*let arr=[];
- let key=true;
- while(key!=false){
- key=prompt('Введите элемент массива','');
- if(key==null){
- break;
- }else{
- arr.push(key);
- }
- }
- console.log(arr);*/
- //------array fill nipush
- /*let arr=[];
- let i=0;
- let key=true;
- while(key!=false){
- key=prompt('Введите элемент массива','');
- if(key==null){
- break;
- }else{
- arr[i++]=key;
- }
- }
- console.log(arr);*/
- //------infinite probability
- /*let b=0;
- for(let i=10;i-->0;i++){
- if(Math.random()>0.9){
- break;
- }else{
- ++b;
- }
- }
- console.log(b);*/
- //------empty loop
- /*let key=true;
- while(key!=false){
- key = prompt('','');
- if(null){
- continue;
- }
- }
- console.log(key);*/
- //------progressive sum
- /*let sum=0;
- let n=1;
- for(let i=0;i<15;i++){
- console.log(n);
- sum+=n;
- n+=3;
- }
- console.log(sum);*/
- //------chess one line
- /*let str='';
- for(let i=0;i<=Math.round(Math.random()*10);i++){
- str+='# ';
- }
- console.log(str);*/
- //------numbers
- /*let str='';
- for(let i=0;i<10;i++){
- str+='<br/>';
- for(let j=0;j<=9;j++){
- str+=j;
- }
- }
- document.write(str);*/
- //------chess
- /*let str='';
- for(let i=0;i<10;i++){
- if(i%2){
- for(let j=0;j<10;j++){
- if(j%2){
- str+=' #';
- }else{
- str+=' .';
- }
- }
- }else{
- for(let j=0;j<10;j++){
- if(j%2){
- str+=' .';
- }else{
- str+=' #';
- }
- }
- }
- str+='<br/>';
- }
- document.write(str);*/
-
- //------cubes
- /*let arr=[0,1,2,3,4,5,6,7,8,9];
- let arr2=arr.map(x=>x*x*x);
- console.log(arr2);*/
- //------multiply table && matrix to html table
- /*let arr=[];
- for(let i=0;i<=10;i++){
- arr[0]='<table>'
- arr[i]=[];
- for(let j=0;j<=10;j++){
- arr[i][0]='<tr>';
- if(i>0){
- arr[i][j]='<td>'+i*j+'</td>';
- }
- if(j==10){
- arr[i][j]='</tr>';
- }
- }
- arr[11]='</table>';
- }
- str=arr.join(' ').replace(/[\s.,%]/g,'');
- document.write(str);*/
- //------blue belt [треугольник]
- /*let arr=[];
- for(let i=0;i<=5;i++){
- arr[0]='<table>';
- arr[i]=[];
- for(let j=0;j<=10;j++){
- arr[i][0]='<tr>';
- arr[i][5]='<td>'+'#'+'</td>';
- if(i>1){
- arr[i][6]='<td>'+'#'+'</td>';
- arr[i][4]='<td>'+'#'+'</td>';
- }
- if(i>2){
- arr[i][7]='<td>'+'#'+'</td>';
- arr[i][3]='<td>'+'#'+'</td>';
- }
- if(i>3){
- arr[i][8]='<td>'+'#'+'</td>';
- arr[i][2]='<td>'+'#'+'</td>';
- }
- if(i>4){
- arr[i][9]='<td>'+'#'+'</td>';
- arr[i][1]='<td>'+'#'+'</td>';
- }
- if(i>0){
- arr[i][j]='<td>'+"."+'</td>';
- }
- arr[i][10]='</tr>';
- }
- arr[11]='</table>';
- }
- str=arr.join(' ').replace(/[\s.,%]/g,'');
- document.write(str);*/
- //------Black belt [элуктронная гадалка]
- let n=Math.floor(Math.random()*2);
- console.log(n)
- let history=[];
- let key=prompt('Ваше число: 0 или 1','');
- key==n?alert('Congrats'):alert('Sorry');
- console.log(history);
-
- // в процессе
-
-
-
- </script>
- </body>
- </html>
|