Skip to content

Commit 7197fed

Browse files
authored
Merge pull request #17 from EasyCode-JavaScriptReact-v1/homework_14
homework_14
2 parents ab8a9a9 + 4c7563a commit 7197fed

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
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+
<script src="index.js"></script>
38+
</body>
39+
</html>
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
let app = {
64+
questions: [
65+
{
66+
textQuestions:'Вопрос №1',
67+
textAnswers: ['Вариант ответа №1', 'Вариант ответа №2', 'Вариант ответа №3']
68+
},
69+
{
70+
textQuestions:'Вопрос №2',
71+
textAnswers: ['Вариант ответа №1', 'Вариант ответа №2', 'Вариант ответа №3']
72+
},
73+
{
74+
textQuestions:'Вопрос №3',
75+
textAnswers: ['Вариант ответа №1', 'Вариант ответа №2', 'Вариант ответа №3']
76+
}
77+
],
78+
createContainer() {
79+
let container = document.createElement('article');
80+
container.appendChild(this.createCaption());
81+
container.appendChild(this.createQuestions());
82+
container.appendChild(this.createButton());
83+
return container;
84+
},
85+
createCaption() {
86+
let caption = document.createElement('h1');
87+
caption.textContent = 'Тест по програмированию';
88+
return caption;
89+
},
90+
createQuestions() {
91+
let id = 0;
92+
let list = document.createElement('ol');
93+
this.questions.forEach((questAnswer) => {
94+
let question = document.createElement('li');
95+
question.textContent = questAnswer.textQuestions;
96+
let sectionAnswer = document.createElement('section');
97+
question.appendChild(sectionAnswer);
98+
99+
questAnswer.textAnswers.forEach((elem) => {
100+
let idId = id++;
101+
let answer = document.createElement('p');
102+
let input = document.createElement('input');
103+
input.setAttribute('type', 'checkbox');
104+
input.setAttribute('id', `check${idId}`);
105+
let label = document.createElement('label');
106+
label.setAttribute('for', `check${idId}`);
107+
label.textContent = elem;
108+
answer.appendChild(input);
109+
answer.appendChild(label);
110+
111+
sectionAnswer.appendChild(answer);
112+
question.appendChild(sectionAnswer);
113+
list.appendChild(question);
114+
});
115+
});
116+
return list;
117+
},
118+
createButton() {
119+
let button = document.createElement('button');
120+
button.textContent = 'Проверить мои результаты';
121+
return button;
122+
},
123+
render() {
124+
document.body.appendChild(this.createContainer());
125+
}
126+
};
127+
app.render();
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)