diff --git a/1-js/05-data-types/03-string/article.md b/1-js/05-data-types/03-string/article.md index 8f8a40c5..b74399a9 100644 --- a/1-js/05-data-types/03-string/article.md +++ b/1-js/05-data-types/03-string/article.md @@ -19,7 +19,7 @@ let double = "double-quoted"; let backticks = `backticks`; ``` -Single and double quotes are essentially the same. Backticks however allow us to embed any expression into the string, including function calls: +Single and double quotes are essentially the same. Backticks, however, allow us to embed any expression into the string, including function calls: ```js run function sum(a, b) { @@ -89,7 +89,7 @@ Examples with unicode: ```js run alert( "\u00A9" ); // © alert( "\u{20331}" ); // 佫, a rare chinese hieroglyph (long unicode) -alert( "\u{1F60D}"); // 😍, a smiling face symbol (another long unicode) +alert( "\u{1F60D}" ); // 😍, a smiling face symbol (another long unicode) ``` All special characters start with a backslash character `\`. It is also called an "escape character". @@ -166,7 +166,7 @@ alert( str.charAt(1000) ); // '' (an empty string) We can also iterate over characters using `for..of`: ```js run -for(let char of "Hello") { +for (let char of "Hello") { alert(char); // H,e,l,l,o (char becomes "H", then "e", then "l" etc) } ``` @@ -379,8 +379,8 @@ There are 3 methods in JavaScript to get a substring: `substring`, `substr` and ```js run let str = "stringify"; - alert( str.slice(0,5) ); // 'strin', the substring from 0 to 5 (not including 5) - alert( str.slice(0,1) ); // 's', from 0 to 1, but not including 1, so only character at 0 + alert( str.slice(0, 5) ); // 'strin', the substring from 0 to 5 (not including 5) + alert( str.slice(0, 1) ); // 's', from 0 to 1, but not including 1, so only character at 0 ``` If there is no second argument, then `slice` goes till the end of the string: @@ -548,7 +548,7 @@ For instance: alert( 'Österreich'.localeCompare('Zealand') ); // -1 ``` -This method actually has two additional arguments specified in [the documentation](mdn:js/String/localeCompare), which allow it to specify the language (by default taken from the environment) and setup additional rules like case sensivity or should `"a"` and `"á"` be treated as the same etc. +This method actually has two additional arguments specified in [the documentation](mdn:js/String/localeCompare), which allows it to specify the language (by default taken from the environment) and setup additional rules like case sensitivity or should `"a"` and `"á"` be treated as the same etc. ## Internals, Unicode diff --git a/1-js/05-data-types/04-array/article.md b/1-js/05-data-types/04-array/article.md index 8246c9dd..825cfbed 100644 --- a/1-js/05-data-types/04-array/article.md +++ b/1-js/05-data-types/04-array/article.md @@ -297,7 +297,7 @@ But for arrays there is another form of loop, `for..of`: let fruits = ["Apple", "Orange", "Plum"]; // iterates over array elements -for(let fruit of fruits) { +for (let fruit of fruits) { alert( fruit ); } ``` @@ -356,7 +356,7 @@ arr.length = 5; // return length back alert( arr[3] ); // undefined: the values do not return ``` -So, the simplest way to clear the array is: `arr.length=0`. +So, the simplest way to clear the array is: `arr.length = 0;`. ## new Array() [#new-array] @@ -385,9 +385,9 @@ In the code above, `new Array(number)` has all elements `undefined`. To evade such surprises, we usually use square brackets, unless we really know what we're doing. -## Multidimentional arrays +## Multidimensional arrays -Arrays can have items that are also arrays. We can use it for multidimentional arrays, to store matrices: +Arrays can have items that are also arrays. We can use it for multidimensional arrays, to store matrices: ```js run let matrix = [ @@ -458,9 +458,9 @@ We can use an array as a deque with the following operations: - `unshift(...items)` adds items to the beginning. To loop over the elements of the array: - - `for(let i=0; i. diff --git a/1-js/06-advanced-functions/08-settimeout-setinterval/article.md b/1-js/06-advanced-functions/08-settimeout-setinterval/article.md index ec645913..6bd4000a 100644 --- a/1-js/06-advanced-functions/08-settimeout-setinterval/article.md +++ b/1-js/06-advanced-functions/08-settimeout-setinterval/article.md @@ -325,7 +325,7 @@ Then the next call is scheduled in `(*)` if we're not done yet. Pauses between `count` executions provide just enough "breath" for the JavaScript engine to do something else, to react on other user actions. -The notable thing is that both variants: with and without splitting the job by `setInterval` -- are comparable in speed. There's no much difference in the overall counting time. +The notable thing is that both variants: with and without splitting the job by `setTimeout` -- are comparable in speed. There's no much difference in the overall counting time. To make them closer let's make an improvement. @@ -461,4 +461,4 @@ For example, the in-browser timer may slow down for a lot of reasons: - The browser tab is in the background mode. - The laptop is on battery. -All that may decrease the minimal timer resolution (the minimal delay) to 300ms or even 1000ms depending on the browser and settings. +All that may increase the minimal timer resolution (the minimal delay) to 300ms or even 1000ms depending on the browser and settings.