Mark 2 years ago
parent
commit
665d224b7e
4 changed files with 104 additions and 0 deletions
  1. 1 0
      04/main.js
  2. 70 0
      06/main.js
  3. 33 0
      07/index.html
  4. 0 0
      07/main.js

+ 1 - 0
04/main.js

@@ -273,3 +273,4 @@ console.log(body.subTags[1].subTags[1].text)
 // document.write(str);
 
 
+

+ 70 - 0
06/main.js

@@ -0,0 +1,70 @@
+// a
+function a() {
+   alert('Привет');
+}
+a()
+
+// cube
+function cube() {
+   console.log(prompt('number') ** 3);
+}
+cube()
+
+// avg2
+function avg2(a, b) {
+   console.log((a + b) / 2);
+}
+avg2(5, 10)
+avg2(1, 2)
+
+// sum3
+function sum3(a, b, c) {
+   a = a || 0;
+   b = b || 0;
+   c = c || 0;
+   return a + b + c;
+}
+console.log(sum3(1, 2, 3))
+console.log(sum3(5, 10, 100500))
+console.log(sum3(5, 10))
+
+// intRandom
+function intRandom(min, max) {
+   min = min || 0;
+   max = max || 0;
+   let result = Math.random() * (max - min) + min;
+   return Math.round(result)
+}
+console.log(intRandom(2, 15))
+console.log(intRandom(-1, -1))
+console.log(intRandom(0, 1))
+console.log(intRandom(10))
+
+// greetAll
+function greetAll(...arguments) {
+   for (let arg of arguments) {
+      alert(`Hello ${arg}!`)
+   }
+}
+greetAll("Superman")
+greetAll("Superman", "SpiderMan")
+greetAll("Superman", "SpiderMan", "Captain Obvious")
+
+
+// sum
+function sum(...arguments) {
+   let result = 0
+   for (let arg of arguments) {
+      result += arg
+
+   }
+   console.log(result)
+}
+sum(1)
+sum(2)
+sum(10, 20, 40, 100)
+
+// Union
+
+
+

+ 33 - 0
07/index.html

@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+
+<head>
+   <title>
+      Static File Index.HTML
+   </title>
+   <script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js'></script>
+</head>
+
+<body>
+   <div id='formContainer'>
+      <input id="nickname" type="text">
+      <input id="msg" type="text">
+      <button id="button">enter</button>
+   </div>
+   <script>
+      const socket = io("http://socketchat.ed.asmer.org.ua/")
+      socket.emit('msg', { nick: "test", message: "txt" })
+      socket.on('msg', msg => {
+         console.log(msg)
+
+         let p = document.createElement("div")
+         document.body.append(p)
+         p.innerHTML = msg.nick
+      })
+      button.onclick = function () {
+         socket.emit('msg', { nick: "test", message: "txt" })
+      }
+   </script>
+</body>
+
+</html>

+ 0 - 0
07/main.js