File tree Expand file tree Collapse file tree 2 files changed +0
-43
lines changed
modules/45-logic/28-logical-negation Expand file tree Collapse file tree 2 files changed +0
-43
lines changed Original file line number Diff line number Diff line change @@ -16,19 +16,6 @@ theory: |
1616
1717 I.e., we can just put a `!` to the left of the function call and get the opposite result.
1818
19- Negation works for any expression. Any value will be cast to the opposite boolean value.
20-
21- ```javascript
22- const message = 'Hello, world!';
23- // Works with constants and variables
24- !message; // false
25-
26- // And directly with the values
27- !5; // false
28- !'hello'; // false
29- !0; // true
30- ```
31-
3219 Negation is a powerful tool that allows you to concisely express the desired rules in your code without having to write new functions.
3320
3421 What if you wrote `!!isEven(10)` like this? Suddenly, the code would work. Double negation in logic is equivalent to no negation at all.
@@ -39,14 +26,6 @@ theory: |
3926 !!isEven(10); // true
4027 ```
4128
42- Negatives can be inside other expressions.
43-
44- ```javascript
45- true && !false; // true
46- !false || false; // true
47- !!isEven(10) && !'hello'; // false
48- !!isEven(10) && !!'hello'; // true
49-
5029instructions : |
5130
5231 1. Write a function, `isPalindrome()`, to check if a word is a palindrome. A palindrome is a word that reads the same backwards as it does forwards.
Original file line number Diff line number Diff line change @@ -16,19 +16,6 @@ theory: |
1616
1717 То есть мы просто добавили `!` слева от вызова функции и получили обратное действие.
1818
19- Отрицание работает для любых выражений. Любое значение будет приведено к противоположному значению логического типа.
20-
21- ```javascript
22- const message = 'Hello, world!';
23- // Работает с константами и переменными
24- !message; // false
25-
26- // И напрямую со значениями
27- !5; // false
28- !'hello'; // false
29- !0; // true
30- ```
31-
3219 Отрицание — мощный инструмент, который позволяет лаконично выражать задуманные правила в коде без необходимости писать новые функции.
3320
3421 А что если написать так `!!isEven(10)`? Внезапно, но код сработает. В логике двойное отрицание подобно отсутствию отрицания вообще.
@@ -39,15 +26,6 @@ theory: |
3926 !!isEven(10); // true
4027 ```
4128
42- Отрицания могут быть внутри других выражений.
43-
44- ```javascript
45- true && !false; // true
46- !false || false; // true
47- !!isEven(10) && !'hello'; // false
48- !!isEven(10) && !!'hello'; // true
49- ```
50-
5129instructions : |
5230
5331 В этом уроке вам нужно будет реализовать две функции `isPalindrome()` и `isNotPalindrome()`
You can’t perform that action at this time.
0 commit comments