Skip to content

Commit 7227ab3

Browse files
Balashov NikitaOlegLustenko
authored andcommitted
classwork-14
1 parent 3788dce commit 7227ab3

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Class work 14</title>
6+
</head>
7+
<body>
8+
<script src="src/main.js"></script>
9+
</body>
10+
</html>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Regural Expressions
2+
3+
let myReguralExpression = /java-script/;
4+
5+
console.log(myReguralExpression.test('java-script'));
6+
7+
const myNewRegExp = new RegExp('some');
8+
9+
console.log(myNewRegExp.test('some'));
10+
11+
// []
12+
console.log('--------');
13+
14+
let checkRegExp = new RegExp('[A-C]');
15+
16+
console.log(checkRegExp.test('A'));
17+
console.log(checkRegExp.test('B'));
18+
console.log(checkRegExp.test('C'));
19+
console.log(checkRegExp.test('a'));
20+
console.log(checkRegExp.test('b'));
21+
console.log(checkRegExp.test('D'));
22+
23+
// Task 1
24+
25+
function check(string) {
26+
const rightAnswer = new RegExp('JavaScript');
27+
return rightAnswer.test(string);
28+
}
29+
30+
console.log(check('JavaScript'));
31+
console.log(check('JavaScrpt'));
32+
33+
//----------
34+
35+
const superJs = 'JS is is is is awesome';
36+
37+
console.log(superJs.replace(/is/gi, 'are'));
38+
39+
/*
40+
i - делает не чувствительным к регистру
41+
g - заменяет все совпадения
42+
*/
43+
44+
//Task 2
45+
46+
function holdOneIs(string) {
47+
const secretKey = '%_%_%';
48+
return string.replace(/is/i, secretKey).replace(/is /gmi, '').replace(secretKey, 'is');
49+
}
50+
51+
console.log(holdOneIs(superJs));
52+
53+
// ^ логическое НЕ
54+
55+
//DOM
56+
57+
const div = document.createElement('div');
58+
div.textContent = 'content';
59+
60+
console.dir(div);
61+
62+
const div2 = document.createElement('div');
63+
64+
div.append(div2);
65+
66+
console.log(div);
67+
68+
document.body.appendChild(div);
69+
70+
//Task 3
71+
72+
const ul = document.createElement('ul');
73+
const firstLi = document.createElement('li');
74+
const secondLi = document.createElement('li');
75+
const thirdLi = document.createElement('li');
76+
77+
firstLi.textContent = 'JavaScript';
78+
secondLi.textContent = 'React';
79+
thirdLi.textContent = 'Node.js';
80+
81+
ul.append(firstLi);
82+
ul.append(secondLi);
83+
ul.append(thirdLi);
84+
85+
document.body.appendChild(ul);
86+
// -----------
87+
const ul2 = document.createElement('ul');
88+
// Визуализация данных
89+
const content = ['qwerty', 'test', 'EPAM', 'awda'];
90+
91+
for(let i = 0; i < content.length; i++) {
92+
let li = document.createElement('li');
93+
li.textContent = content[i];
94+
ul2.append(li);
95+
}
96+
97+
document.body.appendChild(ul2);

0 commit comments

Comments
 (0)