1+ // TASK 1
2+ const solution = str => {
3+ let regExpLetter = / [ a - z ] / g;
4+ let regExpNunber = / [ 0 - 9 ] / ;
5+ if ( str . search ( regExpNunber ) === 0 ) {
6+ return false ;
7+ } ;
8+ if ( str . search ( regExpLetter ) === 0 ) {
9+ let arrFromRegExp = str . match ( regExpLetter ) ;
10+ let newArrWithoutRepetition = [ ] ;
11+ for ( let i = 0 ; i < arrFromRegExp . length ; i ++ ) {
12+ for ( let k = 0 ; k < newArrWithoutRepetition . length ; k ++ ) {
13+ if ( newArrWithoutRepetition [ k ] == arrFromRegExp [ i ] ) {
14+ newArrWithoutRepetition . splice ( k , 1 ) ;
15+ } ;
16+ } ;
17+ newArrWithoutRepetition . push ( arrFromRegExp [ i ] ) ;
18+ } ;
19+ if ( newArrWithoutRepetition . length === 26 ) {
20+ return true ;
21+ } else {
22+ return false ;
23+ } ;
24+ } ;
25+ } ;
26+
27+ console . log ( 'Task1 ---> ' , solution ( "wyyga" ) ) ; //false
28+ console . log ( 'Task1 ---> ' , solution ( "qwertyuioplkjhgfdsazxcvbnm" ) ) ; //true
29+ console . log ( 'Task1 ---> ' , solution ( "ejuxggfsts" ) ) ; //false
30+ console . log ( 'Task1 ---> ' , solution ( "qpwoeirutyalskdjfhgmznxbcv" ) ) ; //true
31+ console . log ( 'Task1 ---> ' , solution ( "qqqqqqqqpwoeirutyallskkdjfhgmmznxbcv" ) ) ; //true
32+ console . log ( 'Task1 ---> ' , solution ( "0123456789abcdefghijklmnop" ) ) ; //false
33+
34+
35+
36+ //TASK2
37+ const flatten = arr => {
38+ let arr2 = [ ] ;
39+ arr . forEach ( ( elem ) => {
40+ if ( ! Array . isArray ( elem ) ) {
41+ arr2 . push ( elem ) ;
42+ } else {
43+ arr2 = arr2 . concat ( flatten ( elem ) ) ;
44+ } ;
45+ } ) ;
46+ return arr2 ;
47+ } ;
48+
49+ console . log ( 'Task2 ---> ' , flatten ( [ 1 , [ 2 , [ { a : "b" , c : 'd' } , { c : [ 1 , 2 , 5 ] } ] ] ] ) ) ;
50+ console . log ( 'Task2 ---> ' , flatten ( [ [ 1 , 2 ] , [ 3 , [ 4 ] ] , 5 , 10 ] ) ) ;
51+ console . log ( 'Task2 ---> ' , flatten ( [ 25 , 10 , [ 10 , [ 15 ] ] ] ) ) ;
52+
53+
54+
55+
56+ //Task3
57+ class UsersContacts {
58+ constructor ( ) {
59+ this . dataUsers = [
60+ {
61+ name : 'Иван' ,
62+ lastName : 'Петров' ,
63+ email : 'IvanPetrov@ec.ua'
64+ } ,
65+ {
66+ name : 'Сергей' ,
67+ lastName : 'Сергей' ,
68+ email : 'SergeiSergeev@ec.ua'
69+ } ,
70+ {
71+ name : 'Иван' ,
72+ lastName : 'Иванов' ,
73+ email : 'IvanIvanov@ec.ua'
74+ } ,
75+ {
76+ name : 'Александр' ,
77+ lastName : 'Александров' ,
78+ email : 'AlexAlex@ec.ua'
79+ } ,
80+ {
81+ name : 'Алекс' ,
82+ lastName : 'Смирнов' ,
83+ email : 'AlexSmirnov@ec.ua'
84+ } ,
85+ {
86+ name : 'Сергей' ,
87+ lastName : 'Волков' ,
88+ email : 'VolkovSergey@ec.ua'
89+ } ,
90+ {
91+ name : 'Мария' ,
92+ lastName : 'Шарапова' ,
93+ email : 'MariyaSharapova@ec.ua'
94+ } ,
95+ {
96+ name : 'Александр' ,
97+ lastName : 'Винник' ,
98+ email : 'AlexVinnik@ec.u'
99+ } ,
100+ {
101+ name : 'Дарий' ,
102+ lastName : 'Смирнов' ,
103+ email : 'DariySmirnov@ec.ua'
104+ } ,
105+ {
106+ name : 'Елена' ,
107+ lastName : 'Лещенко' ,
108+ email : 'ElenaLeshenko@ec.ua'
109+ } ,
110+ {
111+ name : 'Ольга' ,
112+ lastName : 'Новикова' ,
113+ email : 'OlgaNovikova@ec.ua'
114+ } ,
115+ {
116+ name : 'Наталья' ,
117+ lastName : 'Шемякина' ,
118+ email : 'ShemyakinaN@ec.ua'
119+ } ,
120+ {
121+ name : 'Анна' ,
122+ lastName : 'Донцова' ,
123+ email : 'AnnaDontsova@ec.ua'
124+ } ,
125+ {
126+ name : 'Влад' ,
127+ lastName : 'Яма' ,
128+ email : 'VladYama@ec.ua'
129+ } ,
130+ {
131+ name : 'Кира' ,
132+ lastName : 'Воробьева' ,
133+ email : 'Kira1990@ec.ua'
134+ } ,
135+ {
136+ name : 'Виктор' ,
137+ lastName : 'Кривенко' ,
138+ email : 'ViktorKriv@ec.ua'
139+ }
140+ ] ;
141+ this . columnHeadings = [ 'Name' , 'Last name' , 'Email' ] ;
142+ } ;
143+
144+ render ( ) {
145+ let insert = document . querySelector ( 'main > div' ) ;
146+ insert . appendChild ( this . createTable ( ) ) ;
147+ } ;
148+
149+ createNewElement ( newElem ) {
150+ return document . createElement ( newElem ) ;
151+ } ;
152+
153+ createTable ( ) {
154+ let table = this . createNewElement ( 'table' ) ;
155+ table . setAttribute ( 'class' , 'table table-hover contacts' ) ;
156+ table . appendChild ( this . cteateTheadInTable ( ) ) ;
157+ table . appendChild ( this . cteateTbodyInTable ( ) ) ;
158+ return table ;
159+ } ;
160+
161+ cteateTheadInTable ( ) {
162+ let thead = this . createNewElement ( 'thead' ) ;
163+ let tr = this . createNewElement ( 'tr' ) ;
164+ thead . appendChild ( tr ) ;
165+ this . columnHeadings . forEach ( ( elem ) => {
166+ let th = this . createNewElement ( 'th' ) ;
167+ th . textContent = elem ;
168+ tr . appendChild ( th ) ;
169+ } ) ;
170+ return thead ;
171+ } ;
172+
173+ cteateTbodyInTable ( ) {
174+ let tbody = this . createNewElement ( 'tbody' ) ;
175+ //table.appendChild(tbody);
176+ this . dataUsers . forEach ( ( elem ) => {
177+ let tr = this . createNewElement ( 'tr' )
178+ tbody . appendChild ( tr ) ;
179+ let arrObjkeys = Object . keys ( elem ) ;
180+ arrObjkeys . forEach ( ( elemTd ) => {
181+ let td = this . createNewElement ( 'td' ) ;
182+ td . textContent = elem [ elemTd ] ;
183+ tr . appendChild ( td ) ;
184+ } ) ;
185+ } ) ;
186+ return tbody ;
187+ } ;
188+ } ;
189+
190+ let usersContacts = new UsersContacts ( ) ;
191+ usersContacts . render ( ) ;
0 commit comments