From 5a1b4978cb3601a2774a080bd3694a76e0318a69 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Mon, 1 Jan 2018 19:30:14 +0200 Subject: [PATCH] Update isSorted to use a proper name --- snippets/{isArraySorted.md => isSorted.md} | 12 ++++++------ tag_database | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) rename snippets/{isArraySorted.md => isSorted.md} (76%) diff --git a/snippets/isArraySorted.md b/snippets/isSorted.md similarity index 76% rename from snippets/isArraySorted.md rename to snippets/isSorted.md index e054697c2..3a8fa2461 100644 --- a/snippets/isArraySorted.md +++ b/snippets/isSorted.md @@ -1,4 +1,4 @@ -### functionName +### isSorted Returns `1` if the array is sorted in ascending order, `-1` if it is sorted in descending order or `0` if it is not sorted. @@ -7,7 +7,7 @@ Use `Object.entries()` to loop over array objects and compare them in pairs. Return `0` if the `direction` changes or the `direction` if the last element is reached. ```js -const isArraySorted = arr => { +const isSorted = arr => { const direction = arr[0] > arr[1] ? -1 : 1; for (let [i, val] of arr.entries()) if (i === arr.length - 1) return direction; @@ -16,8 +16,8 @@ const isArraySorted = arr => { ``` ```js -isArraySorted([0, 1, 2, 3]); // 1 -isArraySorted([0, 1, 2, 2]); // 1 -isArraySorted([4, 3, 2]); // -1 -isArraySorted([4, 3, 5]); // 0 +isSorted([0, 1, 2, 3]); // 1 +isSorted([0, 1, 2, 2]); // 1 +isSorted([4, 3, 2]); // -1 +isSorted([4, 3, 5]); // 0 ``` diff --git a/tag_database b/tag_database index 8163643ee..953c59509 100644 --- a/tag_database +++ b/tag_database @@ -71,7 +71,7 @@ isAbsoluteURL:string isArmstrongNumber:math isArray:utility isArrayLike:utility -isArraySorted:array +isSorted:array isBoolean:utility isDivisible:math isEven:math