Skip to content

Commit 787a7d5

Browse files
homework_14
1 parent e65dd72 commit 787a7d5

File tree

3 files changed

+184
-0
lines changed

3 files changed

+184
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>homework_14</title>
5+
<meta charset="utf-8" />
6+
<link rel="stylesheet" type="text/css" href="style.css">
7+
<script src="index.js"></script>
8+
</head>
9+
<body>
10+
<article>
11+
<h1>Тест по програмированию</h1>
12+
<ol>
13+
<li>Вопрос №1
14+
<section>
15+
<p><input type="checkbox" id="check1-1"><label for="check1-1">Вариант ответа №1</label></p>
16+
<p><input type="checkbox" id="check2-1"><label for="check2-1">Вариант ответа №2</label></p>
17+
<p><input type="checkbox" id="check3-1"><label for="check3-1">Вариант ответа №3</label></p>
18+
</section>
19+
</li>
20+
<li>Вопрос №2
21+
<section>
22+
<p><input type="checkbox" id="check1-2"><label for="check1-2">Вариант ответа №1</label></p>
23+
<p><input type="checkbox" id="check2-2"><label for="check2-2">Вариант ответа №2</label></p>
24+
<p><input type="checkbox" id="check3-2"><label for="check3-2">Вариант ответа №3</label></p>
25+
</section>
26+
</li>
27+
<li>Вопрос №3
28+
<section>
29+
<p><input type="checkbox" id="check1-3"><label for="check1-3">Вариант ответа №1</label></p>
30+
<p><input type="checkbox" id="check2-3"><label for="check2-3">Вариант ответа №2</label></p>
31+
<p><input type="checkbox" id="check3-3"><label for="check3-3">Вариант ответа №3</label></p>
32+
</section>
33+
</li>
34+
</ol>
35+
<button>Проверить мои результаты</button>
36+
</article>
37+
</body>
38+
</html>
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//TASK 0
2+
//let solution = [12, 23, 34, 12, 12, 23, 12, 45];
3+
let solution = [4, 4, 100, 5000, 4, 4, 4, 4, 4, 100, 100,];
4+
//let solution = [3, 3, 4, 6, 4, 5, 9, 9, 21, 9];
5+
//let solution = [4, 8, 15, 16, 23, 42, 4, 15, 42, 42];
6+
//let solution = [2, 2, 44, 44];
7+
8+
function result(arr) {
9+
let resArr = [];
10+
let objNumbers = arr.reduce((done, elem) => {
11+
if(elem in done) {
12+
done[elem] += 1;
13+
} else {
14+
done[elem] = 1;
15+
};
16+
return done;
17+
}, {});
18+
for(let key in objNumbers) {
19+
if(objNumbers[key] % 2 != 0) {
20+
resArr.push(+key);
21+
};
22+
};
23+
return resArr;
24+
};
25+
console.log(result(solution));
26+
27+
28+
29+
30+
//TASK - 1
31+
const someWebpackModule = `module.exports = {
32+
context: %%HOMEDIR%%,
33+
entry: {
34+
app: "%%HOMEDIR%%/%%APP_DIR%%/%%APPNAME%%.js"
35+
},
36+
output: {
37+
path: %%HOMEDIR%% + '/app',
38+
filename: "dist/[%%APPNAME%%].js",
39+
library: '[%%APPNAME%%]'
40+
}
41+
}`;
42+
43+
//TASK - 1
44+
let regExpSetpoint = /%%HOMEDIR%%/gmi;
45+
//let regExpSetpoint = /%%APP_DIR%%/gmi;
46+
//let regExpSetpoint = /%%APPNAME%%/gmi;
47+
48+
let regExpRequiredValue = './JavaScript-Basic';
49+
//let regExpRequiredValue = 'fixtures/src';
50+
//let regExpRequiredValue = 'app.js';
51+
52+
function regExpEndParse(str, setpoints, requiredValue) {
53+
let test = str.replace(setpoints, requiredValue);
54+
return test;
55+
}
56+
57+
console.log(regExpEndParse(someWebpackModule, regExpSetpoint, regExpRequiredValue));
58+
59+
60+
61+
62+
//Task3
63+
window.onload = function() {
64+
let app = {
65+
questions: [
66+
{textQuestions:'Вопрос №1',
67+
textAnswers: ['Вариант ответа №1', 'Вариант ответа №2', 'Вариант ответа №3']},
68+
{textQuestions:'Вопрос №2',
69+
textAnswers: ['Вариант ответа №1', 'Вариант ответа №2', 'Вариант ответа №3']},
70+
{textQuestions:'Вопрос №3',
71+
textAnswers: ['Вариант ответа №1', 'Вариант ответа №2', 'Вариант ответа №3']}
72+
],
73+
createContainer() {
74+
let conteiner = document.createElement('article');
75+
conteiner.appendChild(this.createCaption());
76+
conteiner.appendChild(this.createQuestions());
77+
conteiner.appendChild(this.createButton());
78+
return conteiner;
79+
},
80+
createCaption() {
81+
let caption = document.createElement('h1');
82+
caption.textContent = 'Тест по програмированию';
83+
return caption;
84+
},
85+
createQuestions() {
86+
let id = 0;
87+
let list = document.createElement('ol');
88+
this.questions.forEach((questAnswer) => {
89+
let question = document.createElement('li');
90+
question.textContent = questAnswer.textQuestions;
91+
let sectionAnswer = document.createElement('section');
92+
question.appendChild(sectionAnswer);
93+
94+
questAnswer.textAnswers.forEach((elem) => {
95+
let idId = id++;
96+
let answer = document.createElement('p');
97+
let input = document.createElement('input');
98+
input.setAttribute('type', 'checkbox');
99+
input.setAttribute('id', `check${idId}`);
100+
let label = document.createElement('label');
101+
label.setAttribute('for', `check${idId}`);
102+
label.textContent = elem;
103+
answer.appendChild(input);
104+
answer.appendChild(label);
105+
106+
sectionAnswer.appendChild(answer);
107+
question.appendChild(sectionAnswer);
108+
list.appendChild(question);
109+
});
110+
});
111+
return list;
112+
},
113+
createButton() {
114+
let button = document.createElement('button');
115+
button.textContent = 'Проверить мои результаты';
116+
return button;
117+
},
118+
render() {
119+
document.body.appendChild(this.createContainer());
120+
}
121+
};
122+
app.render();
123+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
h1 {
2+
text-align: center;
3+
}
4+
5+
li {
6+
margin: 0, auto;
7+
}
8+
9+
section {
10+
margin-top: 10px;
11+
margin-bottom: 10px;
12+
}
13+
14+
p {
15+
margin: 0;
16+
}
17+
18+
button {
19+
margin-left: 500px;
20+
height: 40px;
21+
width:350px;
22+
}
23+

0 commit comments

Comments
 (0)