From ad50be199bdb0ac3111f3e0344d523038ea88a30 Mon Sep 17 00:00:00 2001 From: Lavrentiy Rubtsov Date: Sat, 14 May 2022 15:14:26 +0600 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=91=BE=20just=20add=20missed=20break?= =?UTF-8?q?=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/05-data-types/05-array-methods/article.md | 1 + 1 file changed, 1 insertion(+) diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index b14e9a0b..e11246e2 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -389,6 +389,7 @@ Literally, all elements are converted to strings for comparisons. For strings, l To use our own sorting order, we need to supply a function as the argument of `arr.sort()`. The function should compare two arbitrary values and return: + ```js function compare(a, b) { if (a > b) return 1; // if the first value is greater than the second From a85e802056d9587709f0ecb78da0841fb8321c78 Mon Sep 17 00:00:00 2001 From: Lavrentiy Rubtsov Date: Sat, 14 May 2022 15:37:55 +0600 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=91=BE=20remove=20one=20extra=20break?= =?UTF-8?q?=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/05-data-types/05-array-methods/article.md | 1 - 1 file changed, 1 deletion(-) diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index e11246e2..673a1895 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -634,7 +634,6 @@ So it's advised to always specify the initial value. The method [arr.reduceRight](mdn:js/Array/reduceRight) does the same, but goes from right to left. - ## Array.isArray Arrays do not form a separate language type. They are based on objects. From 60209e64d9c28620189ed5f473af9c5ce694dd8f Mon Sep 17 00:00:00 2001 From: Lavrentiy Rubtsov Date: Sat, 14 May 2022 15:41:37 +0600 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=91=BE=20just=20add=20another=20one?= =?UTF-8?q?=20missed=20break=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1-js/05-data-types/05-array-methods/article.md | 1 + 1 file changed, 1 insertion(+) diff --git a/1-js/05-data-types/05-array-methods/article.md b/1-js/05-data-types/05-array-methods/article.md index 673a1895..959c5921 100644 --- a/1-js/05-data-types/05-array-methods/article.md +++ b/1-js/05-data-types/05-array-methods/article.md @@ -746,6 +746,7 @@ These methods are the most used ones, they cover 99% of use cases. But there are These methods behave sort of like `||` and `&&` operators: if `fn` returns a truthy value, `arr.some()` immediately returns `true` and stops iterating over the rest of items; if `fn` returns a falsy value, `arr.every()` immediately returns `false` and stops iterating over the rest of items as well. We can use `every` to compare arrays: + ```js run function arraysEqual(arr1, arr2) { return arr1.length === arr2.length && arr1.every((value, index) => value === arr2[index]);