├── Plan
├── index.html
└── index.js
/Plan:
--------------------------------------------------------------------------------
1 | 1) How create variables let, const
2 | 2) Console and debuger
3 | 3) Basic types typeof
4 | 4) == ===
5 | 5) Math, Number
6 | 6) Template string
7 | 7) Convert to boolean, Number. String
8 | 8) logical operators
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Document
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | // x = 3.14;
2 | // console.log(`variable x`, x);
3 | // let x = 010;
4 | // console.log(`x`, x);
5 | // let public = 1500;
6 | // const apples = 47;
7 | // const grapes = 135;
8 | // debugger;
9 |
10 | // let price;
11 | // const percent = 12;
12 | // console.log(`price`, price);
13 |
14 | // const a = 5;
15 | // const b = "5";
16 |
17 | // console.log(a == b); // true
18 | // console.log(a === b); // false
19 |
20 | // '25px'
21 |
22 | // console.log("яблоки", apples);
23 | // console.log("виноград", grapes);
24 |
25 | // Выведи на экран общее количество яблок и винограда. Разницу яблок и винограда.
26 |
27 | // const apples = 47;
28 | // const grapes = 135;
29 | // const total = apples + grapes;
30 | // console.log(total);
31 | // const diff = apples - grapes;
32 | // console.log(diff);
33 |
34 | // Замени выражение переопределения комбинированным оператором `+=`.
35 |
36 | // let students = 100;
37 | // // students = students + 50;
38 | // students += 50;
39 | // console.log(students);
40 |
41 | // Разбери приоритет операторов в инструкции присвоения значения переменной
42 | // `result`.
43 |
44 | // const result = 108 + 223 - 2 * 5;
45 | // console.log(result);
46 |
47 | // Напиши скрипт, который выводит в консоль округленные вверх/вниз и т.д. значения
48 | // переменной `value`. Используй методы `Math.floor()`, `Math.ceil()` и
49 | // `Math.round()`. Проверь что будет в консоли при значениях `27.3` и `27.9`.
50 |
51 | // const value = 27.5;
52 | // console.log("floor", Math.floor(value));
53 | // console.log("ceil", Math.ceil(value));
54 | // console.log("round", Math.round(value));
55 | // const user1 = 100;
56 | // const user2 = 123;
57 | // const user3 = 34;
58 | // const maxValue = Math.max(user1, user2, user3);
59 |
60 | // Составь фразу с помощью шаблонных строк `A has B bots in stock`, где A, B -
61 | // переменные вставленные в строку.
62 |
63 | // const companyName = "Cyberdyne Systems";
64 | // const repairBots = 150;
65 | // const defenceBots = 50;
66 |
67 | // const message = `${companyName} has ${repairBots + defenceBots} bots in stock`;
68 | // const userName = "Bob";
69 | // const budget = 1500000;
70 | // const filmName = "Batman";
71 | // const date = "23.05.2020";
72 | // const filmMessage = `Привет ${userName}, сегодня вишло ${filmName} , с бюджетом ${budget} и дата проката ${date} `;
73 | // console.log(message); // "Cyberdyne Systems has 200 bots in stock"
74 |
75 | // Каким будет результат выражений?
76 |
77 | // console.log(5 > 4);
78 |
79 | // console.log(10 >= '7');
80 |
81 | // console.log('2' > '12');
82 |
83 | // console.log("12".charCodeAt(0));
84 | // console.log("2".charCodeAt(0));
85 |
86 | // console.log("2" < "12");
87 |
88 | // console.log('4' == 4);
89 |
90 | // console.log('6' === 6);
91 |
92 | // console.log('false' === false);
93 |
94 | // console.log(1 == true); // true
95 |
96 | // console.log( 1 == 1)//
97 |
98 | // console.log(1 === true); // false
99 |
100 | // console.log(1 === 1); // true
101 |
102 | // console.log('0' == false);
103 |
104 | // console.log('0' === false);
105 |
106 | // console.log('Papaya' < 'papaya');
107 |
108 | // console.log("Papaya" === "papaya");
109 |
110 | // console.log(undefined == null);
111 |
112 | // console.log(undefined === null);
113 |
114 | // Каким будет результат выражений?
115 |
116 | // console.log(true && 3);
117 |
118 | // console.log(false && 3);
119 |
120 | // console.log(true && 4 && 'kiwi');
121 |
122 | // console.log(true && 0 && 'kiwi');
123 |
124 | // console.log(true || 3);
125 |
126 | // console.log(true || 3 || 4);
127 |
128 | // console.log(true || false || 7);
129 |
130 | // console.log(null || " " || undefined);
131 |
132 | // console.log((1 && null && 2) > 0);
133 |
134 | // console.log(null > 0)
135 |
136 | // console.log(null || (2 && 3) || 4);
137 |
138 | // console.log(null || 3 || 4);
139 |
140 | // console.log("ghbdsn!" && 25 && null);
141 |
142 | // 0
143 | // ''
144 | // false
145 | // NaN
146 | // null
147 | // undefined
148 | // -0
149 |
150 |
151 | // Отрефактори код так, чтобы в переменную `value` присваивалось значение
152 | // переменной `incomingValue`, если оно не равно `undefined` или `null`. В
153 | // противном случае должно присваиваться значение `defaultValue`. Проверь работу
154 | // скрипта для слепдующих значений переменной `incomingValue`: null, undefined, 0,
155 | // false. Используй оператор `??` (nullish coalescing operator).
156 |
157 | // const incomingValue = 5;
158 | // const defaultValue = 10;
159 | // const value = incomingValue || defaultValue;
160 | // console.log(value);
161 |
162 | // Напиши скрипт который переведёт значение `totalMinutes` (количество минут) в
163 | // строку в формате часов и минут `HH:MM`.
164 |
165 | // - 70 покажет 01:10
166 | // - 450 покажет 07:30
167 | // - 1441 покажет 24:01
168 |
169 | // const totalMinutes = 70;
170 |
171 | // const hours = Math.floor(totalMinutes / 60);
172 | // const minutes = totalMinutes % 60;
173 | // console.log(hours);
174 | // console.log(minutes);
175 |
176 | // const doubleDigitHours = String(hours).padStart(2, 0);
177 | // const doubleDigitMinutes = String(minutes).padStart(2, 0);
178 | // console.log(`${doubleDigitHours}:${doubleDigitMinutes}`);
179 |
--------------------------------------------------------------------------------