Olga1108 4 years ago
parent
commit
2839ad9346
3 changed files with 32 additions and 2 deletions
  1. 2 2
      js8.2/index.html
  2. 12 0
      js8.3/index.html
  3. 18 0
      js8.3/index.js

+ 2 - 2
js8.2/index.html

@@ -3,10 +3,10 @@
     <head>
         <meta charset='UTF-8' />
         <meta name='viewport' content='width=device-width, initial-scale=1.0' />
-        <title>Home Work 7.3 JS</title>
+        <title>Home Work 8.2 JS</title>
     </head>
     <body>
-        <h1>Home Work 7.3</h1>
+        <h1>Home Work 8.2</h1>
         
         <script src='index.js'></script>    
     </body>

+ 12 - 0
js8.3/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' />
+        <title>Home Work 8.3 JS</title>
+    </head>
+    <body>
+        <h1>Home Work 8.3</h1>
+        <script src='index.js'></script>    
+    </body>
+</html>

+ 18 - 0
js8.3/index.js

@@ -0,0 +1,18 @@
+function User ( name ) {
+    this.name = name
+    this.id = this.counter()
+}
+
+User.prototype.counter = (function () {
+    let id = 0
+    return function(){
+        return typeof this.id === 'number' ? this.id : id++
+    }
+})()
+
+var users = [
+    new User ( "Семен" ),
+    new User ( "Антон" ),
+    new User ( "Демьян" ),
+    new User ( "Василий" )
+]