5 changed files with 166 additions and 5 deletions
  1. 53 0
      js/05/esfsef.js
  2. 5 5
      js/05/js/script.js
  3. 0 0
      js/06/css/style.css
  4. 12 0
      js/06/index.html
  5. 96 0
      js/06/js/script.js

+ 53 - 0
js/05/esfsef.js

@@ -0,0 +1,53 @@
+function getMostplayedOpponents() {
+
+    const matches = this.state.wins
+
+    const already: { opponents: { player1: string, player2: string }, matches: MatchResult[] }[] = [];
+
+    for (let index = 0; index < matches.length; index++) {
+        const match = matches[index];
+
+        let alreadyAdded = false
+
+        for (let index = 0; index < already.length; index++) {
+            const alreadyAddedMatch = already[index];
+
+            if (
+                (match.losers[0].name == alreadyAddedMatch.opponents.player1 || match.losers[0].name == alreadyAddedMatch.opponents.player2) &&
+                (match.losers[1].name == alreadyAddedMatch.opponents.player1 || match.losers[1].name == alreadyAddedMatch.opponents.player2)
+            ) {
+
+                // another game to this pair
+                alreadyAdded = true;
+                alreadyAddedMatch.matches.push(match)
+                break;
+            }
+        }
+
+        if (!alreadyAdded) {
+            
+            const pair = {
+                opponents:
+                {
+                    player1: match.losers[0].name,
+                    player2: match.losers[1].name
+                },
+                matches: []
+            };
+
+            //and add another game to the pair
+            pair.matches.push(match);
+
+            //add another pair
+            already.push(pair)
+        }
+    }
+}
+if
+                (matchResult.winners.length == 1 && (result.alias.name == matchResult.winners[0].name || result.alias.name == matchResult.losers[0].name) ||
+                (matchResult.winners.length == 2 && result.partner != undefined && (
+                    (result.alias.name == matchResult.winners[0].name && result.partner.name == matchResult.winners[1].name || result.alias.name == matchResult.winners[1].name && result.partner.name == matchResult.winners[0].name) ||
+                    (result.alias.name == matchResult.losers[0].name && result.partner.name == matchResult.losers[1].name || result.alias.name == matchResult.losers[1].name && result.partner.name == matchResult.losers[0].name)
+                )
+                )
+            )

+ 5 - 5
js/05/js/script.js

@@ -222,13 +222,13 @@
 
 //========================================================================================//
 
-let arr = [1,2,3,4, 5,6,7,10];
-let { length: length, [0]: a, [1]: b, } = arr;
+// let arr = [1,2,3,4, 5,6,7,10];
+// let { length: length, [0]: a, [1]: b, } = arr;
 
 
-console.log('length = ' + length);
-console.log('a = ' + a);
-console.log('b = ' + b);
+// console.log('length = ' + length);
+// console.log('a = ' + a);
+// console.log('b = ' + b);
 
 
 //========================================================================================//

+ 0 - 0
js/06/css/style.css


+ 12 - 0
js/06/index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="stylesheet" href="./css/style.css">
+    <title>Document</title>
+</head>
+<body>
+    <script src="./js/script.js"></script>
+</body>
+</html>

+ 96 - 0
js/06/js/script.js

@@ -0,0 +1,96 @@
+function aSample() {
+    alert('Привет')
+}
+a();
+
+//=======================================================================================//
+
+//                                      cube                                             //
+
+function cubeSample(a) {
+    return Math.pow(a, 3);
+}
+cube(3)
+
+//=======================================================================================//
+
+//                                     avg2                                             //
+
+function avg2Sample(a,b) {
+    return (a + b) / 2
+}
+
+//=======================================================================================//
+
+//                                     sum3                                             //
+
+function sum3Sample(a,b,c) {
+    return (a + b + c)
+}
+
+//=======================================================================================//
+
+//                                  intRandom                                           //
+
+function intRandomSample(min,max) {
+    return Math.round(Math.random() * (max - min) + min)
+}
+
+//=======================================================================================//
+
+//                                   greetAll                                           //
+
+function greetAllSample() {
+    for (let i = 0; i < arguments.length; i++)
+        alert('Hello ' + arguments[i])
+}
+
+//=======================================================================================//
+
+//                                      sum                                              //
+
+function sumSample() {
+    let result = 0;
+  
+    for (let i = 0; i < arguments.length; i++) {
+      result += arguments[i];
+    }
+  
+    return alert(result);
+  }
+
+//=======================================================================================//
+
+//                                     Union                                             //
+
+let sample = prompt("Введите название задания")
+switch (sample.toLowerCase()){
+    case "a": aSample()
+              break;
+    case "cube": cubeSample()
+              break;
+    case "avg2": avg2Sample()
+              break;
+    case "sum3": sum3Sample()
+              break;
+    case "intRandom": intRandomSample()
+              break;
+    case "greetAll": greetAllSample()
+              break;
+    case "sum": sumSample()
+              break;
+}
+
+//=======================================================================================//
+
+//                               Union declarative                                       //
+
+let tasks = {
+    a: aSample(),
+    cube: cubeSample(),
+    avg2: avg2Sample(),
+    sum3: sum3Sample(),
+    intRandom: intRandomSample(),
+    greetAll: greetAllSample(),
+    sum: sumSample(),
+}