Skip to content

Commit 73e546f

Browse files
authored
Merge pull request #2 from EasyCode-JavaScriptReact-v1/homework-2
Homework 2
2 parents a971ad0 + c05499b commit 73e546f

File tree

5 files changed

+253
-0
lines changed

5 files changed

+253
-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 2</title>
6+
</head>
7+
<body>
8+
<script src="src/main.js"></script>
9+
</body>
10+
</html>
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
const oldString = "string";
2+
const commonString = 'string';
3+
const es6String = `string`;
4+
5+
const yearsOld = 1998;
6+
const name = "Nikita";
7+
8+
console.log(name, 'born in', yearsOld);
9+
console.log(`${name} born in ${yearsOld}`);
10+
11+
console.log(`Class
12+
Work`);
13+
14+
const myNameUpperCase = name.toUpperCase();
15+
16+
console.log(myNameUpperCase);
17+
console.log('string'.toUpperCase());
18+
console.log('STRING'.toLowerCase());
19+
20+
console.log(name[0].toUpperCase());
21+
22+
//Name example
23+
24+
const nameExample = 'nikita';
25+
console.log(nameExample[0].toUpperCase() + nameExample[1] + nameExample[2] + nameExample[3] + nameExample[4] + nameExample[5]);
26+
27+
console.log(nameExample[0].toUpperCase() + nameExample.slice(1));
28+
29+
//Slice example
30+
31+
const youtube = 'Yoube';
32+
33+
console.log(youtube.slice(0, 3) + 'tu' + youtube.slice(3, 5));
34+
console.log(`${youtube.slice(0, 3)}tu${youtube.slice(3, 5)}`);
35+
36+
//split example
37+
38+
const myNameArray = 'Nikita Balashov'.split(' ');
39+
40+
console.log(myNameArray);
41+
42+
const date = `01-12-1995`.split('-');
43+
console.log(date);
44+
45+
const somePractical = `array redict reverse`.split('r');
46+
console.log(somePractical);
47+
48+
49+
//replace example
50+
51+
console.log('Yahoo'.replace('a', '@'));
52+
console.log(`Yahoo`.replace(`o`, `@`).replace(`o`, `@`));
53+
54+
//indexOf
55+
56+
console.log(`The Avengers`.indexOf(`e`, 4));
57+
58+
//length
59+
60+
console.log('easy'.length);
61+
62+
//includes
63+
64+
console.log('Boolean'.includes('Boo'));
65+
console.log('Boolean'.includes('t'));
66+
67+
//trim
68+
69+
console.log(`The End`.trim());
70+
71+
//repeat
72+
73+
console.log(`0_0 `.repeat(7));
74+
75+
//math
76+
77+
console.log('' + 10);
78+
console.log(' ' + 10);
79+
80+
console.log([] + []);
81+
console.log([] + {});
82+
83+
console.log(10 == 10);
84+
console.log(`10` == 10);
85+
console.log(`10` === 10);
86+
87+
console.log(`Empty String`, `` == true);
88+
console.log(`One space`, ` ` == true);
89+
90+
console.log(10 % 2);
91+
console.log(15 % 10);
92+
93+
94+
const year2018 = 2018;
95+
console.log(year2018 % 2000);
96+
97+
console.log(!!false == false);
98+
console.log(!false == true);
99+
100+
//Math
101+
102+
console.log(Math.pow(2, 5));
103+
console.log(2 ** 5);
104+
105+
//typeof
106+
107+
console.log(typeof 'typeof');
108+
console.log(typeof 120);
109+
110+
const typeofArray = [1, `2`, 3];
111+
console.log(typeof typeofArray);
112+
console.log(Array.isArray(typeofArray));
113+
114+
console.log(typeof {});
115+
116+
function typeofFunction () {};
117+
console.log(typeof typeofFunction);
118+
119+
console.log(typeof NaN);
120+
121+
//task-1
122+
123+
const student = {
124+
skills: [`JS`, `React`],
125+
salary: `2000$`,
126+
};
127+
128+
student.salary = `3000$`;
129+
student.age =`20`;
130+
131+
student[`offers`] = 5;
132+
133+
console.log(student);
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
console.log('WWW');
2+
console.log('WWW');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Home work 2</title>
6+
</head>
7+
<body>
8+
9+
<script src="src/main.js"></script>
10+
</body>
11+
</html>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//Home Work 2 made by Balashov Nikita
2+
3+
/*======================= TASK 1 Variant-1(hard) =====================*/
4+
5+
function Solution1 () {
6+
7+
let numbers = [25, 1];
8+
let project = 'проект';
9+
let team = `команда`;
10+
let howMuch = 'Сколько';
11+
let sentence = 'нужно программистов чтобы сделать project ?'; /* there is I can use `${project}` but I prefer hard way) I wonna boost my brain */
12+
13+
let sentenceArray = sentence.split(' '); //transform string in array
14+
sentenceArray.splice(4, 5, `${project}?`);
15+
16+
let task1 = [howMuch, sentenceArray.join(' '), `${numbers[1]},`, `${numbers[0]},`, team];
17+
18+
console.log(task1.join(' '));
19+
20+
};
21+
22+
Solution1();
23+
24+
/*There is I trained to use .splice*/
25+
//let arr = ['Нужно', 'программистов', 'чтобы', 'сделать', 'project', '?'];
26+
//arr.splice(4, 5, `${project}`, '?');
27+
//
28+
//console.log(arr.join(' '));
29+
30+
/*======================= TASK 1 Variant-2(easy) =====================*/
31+
32+
function Solution2 () {
33+
34+
let numbers = [25, 1];
35+
let project = 'проект';
36+
let team = `команда`;
37+
let howMuch = 'Сколько';
38+
let sentence = `нужно программистов чтобы сделать ${project}?`;
39+
40+
41+
let task1 = [howMuch, sentence, `${numbers[1]},`, `${numbers[0]},`, team];
42+
43+
console.log(task1.join(' '));
44+
45+
};
46+
47+
Solutin2();
48+
49+
50+
/*======================= TASK 2 =====================*/
51+
52+
let array = [
53+
'Он',
54+
'был больше ни телом, к которому рано или поздно',
55+
'он обнаружил',
56+
'не',
57+
'Так, когда Будда достиг Просветления',
58+
'...',
59+
'что больше',
60+
'ощущает себя мишенью',
61+
'не'
62+
];
63+
64+
let homeSentence = [`${array[4]},`, `${array[2]},`, `${array[6]}`, `${array[3]}`, `${array[7]}.`, `${array[0]}`, `${array[8]}`, `${array[1]}`, `${array[5]}`];
65+
66+
console.log(homeSentence.join(' '));
67+
68+
69+
/*======================= TASK 3 =====================*/
70+
71+
let myObj = {};
72+
73+
myObj.firstValue = `first value`;
74+
myObj.secondValue = `second value`;
75+
myObj['thirdValue'] = `third value`;
76+
myObj['fourthValue'] = `fourth value`;
77+
78+
console.log(myObj);
79+
80+
81+
/*======================= TASK 5 =====================*/
82+
83+
let frameworks = [4.7, 'Angular', '6Angular', 'React/Redux'];
84+
let x = `google released new version ${frameworks[1] + Math.floor(frameworks[0])} But real speed is ${frameworks[frameworks.length - 1]}`;

0 commit comments

Comments
 (0)