-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
139 lines (125 loc) · 4.58 KB
/
Copy pathmain.js
File metadata and controls
139 lines (125 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
TASK 0
Проверьте что строка содержит все символы от "a" до "z"
solution("wyyga") // false
solution("qwertyuioplkjhgfdsazxcvbnm") // true
solution("ejuxggfsts") // false
solution("qpwoeirutyalskdjfhgmznxbcv") // true
solution("qqqqqqqqpwoeirutyallskkdjfhgmmznxbcv") // true
solution("0123456789abcdefghijklmnop") // false
*/
/*Мне такое решение самой не нравиться, но лучше я не придумала((( */
const solution = str => {
var newStr = str.replace(/a/, '$').replace(/b/, '$').replace(/c/, '$').replace(/d/, '$')
.replace(/e/, '$').replace(/f/, '$').replace(/g/, '$').replace(/h/, '$')
.replace(/i/, '$').replace(/j/, '$').replace(/k/, '$').replace(/l/, '$')
.replace(/m/, '$').replace(/n/, '$').replace(/o/, '$').replace(/p/, '$')
.replace(/q/, '$').replace(/r/, '$').replace(/s/, '$').replace(/t/, '$')
.replace(/u/, '$').replace(/v/, '$').replace(/w/, '$').replace(/x/, '$')
.replace(/y/, '$').replace(/z/, '$');
var newArr = newStr.split('');
var count = 0;
newArr.forEach(elem => {
if (elem === '$') {
count ++;
}
});
if (count === 26) {
console.log(true)
} else {
console.log(false)
}
};
solution("wyyga"); //false
solution("qwertyuioplkjhgfdsazxcvbnm");//true
solution("0123456789abcdefghijklmnop"); //false
solution("qpwoeirutyalskdjfhgmznxbcv");// true
solution("qqqqqqqqpwoeirutyallskkdjfhgmmznxbcv");// true
solution("0123456789abcdefghijklmnop");// false
/*
2. Напишите функция которая преобразовывает / открывает
скобки всех вложенных внутри массивов
Необходимо реализовать рекурсивный фызов функции.
Функция должна открывать любое количество
внутренних массивов и объектов
example:
[[1,2],[3,[4]],5, 10] => [1, 2, 3, 4, 5, 10]
[25, 10, [10, [15]]] => [25, 10, 10, 15]
[1, [2, [ {a: "b", c: 'd' }, { c: [1, 2, 5] } ] ] ] => [1, 2, {a: "b"}]
*/
//#1 arr == [...] flattenedArray = [1] + flatten = [2, [{a: "b"}, { c: 'd' }]]
//#2 arr == [2, [ {a: "b"}, { c: 'd' } ] ] flattenedArray = [2] + flatten == [{a: "b"}, { c: 'd' }]
//#3 arr == [ {a: "b"}, { c: 'd' } ] flattenedArray = [{a: "b"}, { c: 'd' }]
//#
const flatten = arr => {
};
/* Рекурсия не получиласьБ решение со сплайсами у меня в 5 хомверке*/
/*
Виртуализировать таблицу, сделать рендер всей
таблицы через JavaScript.
Второй макет.
https://github.com/aleksandra-maslennikova/telephone-book/blob/master/index.html
Выглядеть должно так же: https://aleksandra-maslennikova.github.io/telephone-book/index.html
*/
const users = [
{
name: 'Иван',
lastName: 'Петров',
email: 'ivanpetrov@gmail.com'
},
{
name: 'Сергей',
lastName:'Сергеев',
email: 'sergeysergeev@gmail.com'
},
{
name: 'Иван',
lastName: 'Петров',
email: 'ivanpetrov@gmail.com'
},
{
name: 'Александр',
lastName: 'Александров',
email: 'alex@gmail.com'
},
{
name: 'Алекс',
lastName: 'Смирнов',
email: 'smirnov@gmail.com'
},
];
const colums = ['Name', 'LastName', 'Email'];
const app = {
users,
colums,
newEl(elName) {
return document.createElement(elName);
},
render() {
const main = this.newEl('main');
const table = this.newEl('table');
const tr = this.newEl('tr');
colums.forEach( columName => {
const th = this.newEl('th');
th.textContent = columName;
tr.appendChild(th);
});
table.appendChild(tr);
users.forEach(user => {
const tr = this.newEl('tr');
const td1 = this.newEl('td');
td1.textContent = user.name;
const td2 = this.newEl('td');
td2.textContent = user.lastName;
const td3 = this.newEl('td');
td3.textContent = user.lastName;
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
table.appendChild(tr);
});
main.appendChild(table);
document.body.appendChild(main);
}
};
app.render();