From db4d0de26d75a134ebccbdc1ccabe01724ac4f41 Mon Sep 17 00:00:00 2001 From: Ilya Kantor Date: Mon, 6 May 2019 07:44:39 +0200 Subject: [PATCH] fixes --- 1-js/02-first-steps/09-alert-prompt-confirm/article.md | 2 +- 1-js/02-first-steps/10-ifelse/article.md | 10 +++++----- 1-js/02-first-steps/11-logical-operators/article.md | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/1-js/02-first-steps/09-alert-prompt-confirm/article.md b/1-js/02-first-steps/09-alert-prompt-confirm/article.md index f69c2d23..c14e0c85 100644 --- a/1-js/02-first-steps/09-alert-prompt-confirm/article.md +++ b/1-js/02-first-steps/09-alert-prompt-confirm/article.md @@ -1,6 +1,6 @@ # Interaction: alert, prompt, confirm -This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks. +In this part of the tutorial we cover JavaScript language "as is", without environment-specific tweaks. But we'll still be using the browser as our demo environment, so we should know at least a few of its user-interface functions. In this chapter, we'll get familiar with the browser functions `alert`, `prompt` and `confirm`. diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index 1e12fa7b..49c1fc04 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -2,7 +2,7 @@ Sometimes, we need to perform different actions based on different conditions. -To do that, we use the `if` statement and the conditional (ternary) operator which we will be referring to as the “question mark” operator `?` for simplicity. +To do that, we can use the `if` statement and the conditional operator `?`, that's also called a "question mark" operator. ## The "if" statement @@ -103,7 +103,7 @@ In the code above, JavaScript first checks `year < 2015`. If that is falsy, it g There can be more `else if` blocks. The final `else` is optional. -## Ternary operator '?' +## Conditional operator '?' Sometimes, we need to assign a variable depending on a condition. @@ -124,9 +124,9 @@ if (age > 18) { alert(accessAllowed); ``` -The so-called "ternary" or "question mark" operator lets us do that in a shorter and simpler way. +The so-called "conditional" or "question mark" operator lets us do that in a shorter and simpler way. -The operator is represented by a question mark `?`. The formal term "ternary" means that the operator has three operands. It is actually the one and only operator in JavaScript which has that many. +The operator is represented by a question mark `?`. Sometimes it's called "ternary", because the operator has three operands. It is actually the one and only operator in JavaScript which has that many. The syntax is: ```js @@ -141,7 +141,7 @@ For example: let accessAllowed = (age > 18) ? true : false; ``` -Technically, we can omit the parentheses around `age > 18`. The question mark operator has a low precedence, so it executes after the comparison `>`. +Technically, we can omit the parentheses around `age > 18`. The question mark operator has a low precedence, so it executes after the comparison `>`. This example will do the same thing as the previous one: diff --git a/1-js/02-first-steps/11-logical-operators/article.md b/1-js/02-first-steps/11-logical-operators/article.md index 4932020a..0773a10c 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -84,7 +84,7 @@ The OR `||` operator does the following: A value is returned in its original form, without the conversion. -In other words, a chain of OR `"||"` returns the first truthy value or the last one if no such value is found. +In other words, a chain of OR `"||"` returns the first truthy value or the last one if no truthy value is found. For instance: @@ -101,7 +101,7 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl 1. **Getting the first truthy value from a list of variables or expressions.** - Imagine we have several variables which can either contain data or be `null/undefined`. How can we find the first one with data? + Imagine we have a list of variables which can either contain data or be `null/undefined`. How can we find the first one with data? We can use OR `||`: @@ -143,7 +143,7 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl alert(x); // 1 ``` - An assignment is a simple case. Other side effects can also be involved. + An assignment is a simple case. There may be side effects, that won't show up if the evaluation doesn't reach them. As we can see, such a use case is a "shorter way of doing `if`". The first operand is converted to boolean. If it's false, the second one is evaluated.