Vladislav342 2 years ago
parent
commit
1474a717f7
1 changed files with 172 additions and 11 deletions
  1. 172 11
      HW_03/index.html

+ 172 - 11
HW_03/index.html

@@ -7,7 +7,7 @@
 <body>
 
 	<script>
-		//html tree
+//------html tree
 		/*let body={
 			tagName:'body',
 			attrs:{},
@@ -60,7 +60,7 @@
 		}
 		console.log(body.children[0].children[2].attrs.id);*/
 
-		//declarative fields
+//------declarative fields
 		/*let school={
 			clasuxa:{
 				name:prompt('Name of Your classuxa',''),
@@ -77,7 +77,7 @@
 		*/
 
 
-		//object links
+//------object links
 		/*let person={
 			name:'Kiril',
 			surname:'Petrovich'
@@ -89,33 +89,194 @@
 		}
 		console.log(person.gajeti.owner.gajeti);*/
 
-		//imperative array fill 3
+//------imperative array fill 3
 		/*let arr=[];
 		arr[0]=prompt('','');
 		arr[1]=+prompt('','');
 		arr[2]=+prompt('','');
 		console.log(arr);*/
 
-		//while confirm
+//------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
+//------array fill nipush
 		/*let arr=[];
+		let i=0;
 		let key=true;
 		while(key!=false){
 			key=prompt('Введите элемент массива','');
-			arr.push(key);
+			if(key==null){
+					break;
+				}else{
+					arr[i++]=key;	
+				}
 		}
 		console.log(arr);*/
-		//???? при отмене записывает null в массив и продолжает спрашивать новый элемент для записи, при добавлении ||key!=null вечный цикл получается ????????
-//-------------------------------------------
 
-		//
+//------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>