1+ const database = new Database ( 'MY DATABASE' ) ;
2+
3+ function Database ( databaseName ) {
4+ this . databaseName = databaseName ;
5+ }
6+
7+ console . log ( database ) ;
8+
9+ // TASK 1
10+
11+ function CreateNewObject ( myArray , cars , name ) {
12+ this . myArray = myArray ;
13+ this . cars = cars ;
14+ this . name = name ;
15+ }
16+ const arr1 = [ 1 , 2 , 3 , 4 ] ;
17+ const cars = {
18+ name : 'BMW' ,
19+ }
20+ const name = `SOME NAME` ;
21+
22+ const test = new CreateNewObject ( arr1 , cars , name ) ;
23+
24+ console . log ( test ) ;
25+
26+ // TASK 2
27+
28+ function CreateDifferentValue ( ...args ) {
29+ if ( args . length === 0 ) {
30+ return console . log ( `don't have ane arguments` ) ;
31+ }
32+ if ( args . length > 3 ) {
33+ return console . log ( `so much arguments` ) ;
34+ }
35+ for ( let i = 0 ; i < args . length ; i ++ ) {
36+ this [ i ] = args [ i ] ;
37+ }
38+ }
39+
40+ const test2 = new CreateDifferentValue ( 1 , 2 , 3 ) ;
41+ const test3 = new CreateDifferentValue ( ) ;
42+ const test4 = new CreateDifferentValue ( 1 , 2 , 3 , 4 , 5 ) ;
43+
44+ console . log ( test2 ) ;
45+ console . log ( test3 ) ;
46+ console . log ( test4 ) ;
47+
48+ // TASK 3
49+
50+ function Counter ( ) {
51+ let counter = 0 ;
52+ this . counter = function ( ) {
53+ function add ( ) {
54+ return counter += 1 ;
55+ }
56+ return add ( ) ;
57+ }
58+ }
59+
60+ const testing = new Counter ( ) ;
61+ console . log ( testing . counter ( ) ) ;
62+ console . log ( testing . counter ( ) ) ;
63+ console . log ( testing . counter ( ) ) ;
64+ console . log ( testing . counter ( ) ) ;
65+
66+ // TASK 4
67+
68+ Database . prototype . registerUser = function ( name , password ) {
69+ this . user = { name, password} ;
70+ }
71+
72+ const mySQL = new Database ( 'mySQL' ) ;
73+ mySQL . registerUser ( 'name' , '123456' ) ;
74+ console . log ( mySQL ) ;
75+
76+ // TASK 5
77+
78+ function Transport ( color , name , doors ) {
79+ this . color = color ;
80+ this . name = name ;
81+ this . doors = doors ;
82+ this . wheels = 4 ;
83+ }
84+
85+ Transport . prototype . beepBeep = function ( ) {
86+ console . log ( `beep-beep` ) ;
87+ }
88+
89+ const juguli = new Transport ( 'green' , 'juguli' , 4 ) ;
90+
91+ console . log ( juguli ) ;
92+
93+ // TASK 6
94+
95+ function Bus ( ) { }
96+
97+ Bus . prototype = Object . create ( Transport . prototype ) ;
0 commit comments