|
@@ -91,13 +91,18 @@ while(filling1 != null){
|
|
|
i++
|
|
|
}
|
|
|
|
|
|
-// infinite probability(?)
|
|
|
-let a = Math.random()
|
|
|
-let b = 0
|
|
|
-while( a < 0.9){
|
|
|
-b + 1;
|
|
|
-break;
|
|
|
-}
|
|
|
+// 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
|
|
|
|
|
@@ -111,66 +116,46 @@ for(i = 1; i < 50; i+=3){
|
|
|
sum = sum + i}
|
|
|
console.log(sum);
|
|
|
|
|
|
- // chess one line
|
|
|
+
|
|
|
+// chess one line
|
|
|
|
|
|
let c = '';
|
|
|
-for(y = 0;y < 21;y++){
|
|
|
+for(y = 0;y < 16;y++){
|
|
|
if(y % 2 === 1){
|
|
|
c = c + '#'}
|
|
|
else {
|
|
|
-c = c + ' '}}
|
|
|
+c = c + '.'}}
|
|
|
|
|
|
|
|
|
-// numbers
|
|
|
-
|
|
|
-let x = ""
|
|
|
-for (let i = 0; i < 10; i++){
|
|
|
- x = x + "\n"
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 0
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 1
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 2
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 3
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 4
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 5
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 6
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 7
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 8
|
|
|
- for (let i = 0; i < 1; i++){
|
|
|
- x = x + 9
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-console.log(x)
|
|
|
|
|
|
-// chess(??????????)<
|
|
|
+// 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(?????????)
|
|
|
+// cubes(?????????)<
|
|
|
|
|
|
// multiply table
|
|
|
|
|
|
debugger
|
|
|
-var result = '\n';
|
|
|
-for (var f = 1;f < 11; f++){
|
|
|
- for(var j = 1; j < 11; j++){
|
|
|
+let result = '\n';
|
|
|
+for (let f = 1;f < 11; f++){
|
|
|
+ for(let j = 1; j < 11; j++){
|
|
|
result += [f*j] + ' ';
|
|
|
}
|
|
|
result += '\n'
|