From 7fb18e9fc648f6d212a960a65e9d2a5d40ea9b33 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Sat, 6 Jan 2018 14:46:05 +0530 Subject: [PATCH 1/6] isUpperCase --- snippets/isLowerCase.md | 17 +++++++++++++++++ snippets/isUpperCase.md | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 snippets/isLowerCase.md create mode 100644 snippets/isUpperCase.md diff --git a/snippets/isLowerCase.md b/snippets/isLowerCase.md new file mode 100644 index 000000000..0e08b2dbb --- /dev/null +++ b/snippets/isLowerCase.md @@ -0,0 +1,17 @@ +### isLowerCase + +Checks if the provided argument contains anything else than the lowerCase alphabets. If the second argument is provided to be true than numbers and other symbols are considered lowercase too. + +``` js +const isLowerCase = (val,symbol = false) => { + if (symbol) return val === val.toLowerCase() + else return !(/[^a-z]/g.test(val)) +} +``` +```js +isUpperCase('abc'); //true +isUpperCase('abc123@$'); //false +isUpperCase('abc123@$',true); //true +isUpperCase('abc123@$ABCD',true); //false +isUpperCase('abc123@$ABCD'); //false +``` diff --git a/snippets/isUpperCase.md b/snippets/isUpperCase.md new file mode 100644 index 000000000..802eb0a97 --- /dev/null +++ b/snippets/isUpperCase.md @@ -0,0 +1,16 @@ +### isUpperCase + +Checks if the provided argument contains anything else than the upperCase alphabets. If the second argument is provided to be true than numbers and other symbols are considered uppercase too. +``` js +const isUpperCase = (val,symbol = false) => { + if (symbol) return val === val.toUpperCase() + else return!(/[^A-Z]/g.test(val)) +} +``` +``` js +isUpperCase('ABC'); //true +isUpperCase('ABC123@$'); //false +isUpperCase('ABC123@$',true); //true +isUpperCase('ABC123@$abcd',true); //false +isUpperCase('ABC123@$abcd'); //false +``` From 19874c5689c16f04f1d0476d7ab8f86236035ba9 Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Sat, 6 Jan 2018 14:46:39 +0530 Subject: [PATCH 2/6] isLowerCase --- snippets/isLowerCase.md | 2 +- snippets/isUpperCase.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/isLowerCase.md b/snippets/isLowerCase.md index 0e08b2dbb..b975de698 100644 --- a/snippets/isLowerCase.md +++ b/snippets/isLowerCase.md @@ -1,6 +1,6 @@ ### isLowerCase -Checks if the provided argument contains anything else than the lowerCase alphabets. If the second argument is provided to be true than numbers and other symbols are considered lowercase too. +Checks if the provided argument contains anything else than the lowercase alphabets. If the second argument is provided to be true than numbers and other symbols are considered lowercase too. ``` js const isLowerCase = (val,symbol = false) => { diff --git a/snippets/isUpperCase.md b/snippets/isUpperCase.md index 802eb0a97..3d4c74760 100644 --- a/snippets/isUpperCase.md +++ b/snippets/isUpperCase.md @@ -1,6 +1,6 @@ ### isUpperCase -Checks if the provided argument contains anything else than the upperCase alphabets. If the second argument is provided to be true than numbers and other symbols are considered uppercase too. +Checks if the provided argument contains anything else than the uppercase alphabets. If the second argument is provided to be true than numbers and other symbols are considered uppercase too. ``` js const isUpperCase = (val,symbol = false) => { if (symbol) return val === val.toUpperCase() From 484c11c8a0b9286e2660e4916b1c7a1ed040227c Mon Sep 17 00:00:00 2001 From: Rohit Tanwar Date: Sat, 6 Jan 2018 14:49:03 +0530 Subject: [PATCH 3/6] a --- snippets/indexesOf.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 snippets/indexesOf.md diff --git a/snippets/indexesOf.md b/snippets/indexesOf.md deleted file mode 100644 index 3b71bbb83..000000000 --- a/snippets/indexesOf.md +++ /dev/null @@ -1,13 +0,0 @@ -### indexesOf - -Returns an array of indexes at which the `val` occurs in `arr`. If it occurs only once return the `index` and if it never occurs returns `-1` - -``` js -const indexesOf = (arr, val) => { - let indexes = [], i; - for(i = 0; i < arr.length; i++) - if (arr[i] === val) - indexes.push(i); - return indexes.length === 0 ? -1 : indexes.length === 1 indexes.pop() : indexes -} -``` From b61f020f0d47d6bbc43442f4408b942bca23d7d0 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 6 Jan 2018 13:52:30 +0200 Subject: [PATCH 4/6] Update isLowerCase.md --- snippets/isLowerCase.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/snippets/isLowerCase.md b/snippets/isLowerCase.md index b975de698..2e5b1305d 100644 --- a/snippets/isLowerCase.md +++ b/snippets/isLowerCase.md @@ -1,17 +1,15 @@ ### isLowerCase -Checks if the provided argument contains anything else than the lowercase alphabets. If the second argument is provided to be true than numbers and other symbols are considered lowercase too. +Checks if a string is lower case. + +Convert the given string to lower case, using `String.toLowerCase()` and compare it to the original. ``` js -const isLowerCase = (val,symbol = false) => { - if (symbol) return val === val.toLowerCase() - else return !(/[^a-z]/g.test(val)) -} +const isLowerCase = str => str === str.toLowerCase(); ``` + ```js -isUpperCase('abc'); //true -isUpperCase('abc123@$'); //false -isUpperCase('abc123@$',true); //true -isUpperCase('abc123@$ABCD',true); //false -isUpperCase('abc123@$ABCD'); //false +isLowerCase('abc'); //true +isLowerCase('a3@$'); //false +isLowerCase('Ab4'); //false ``` From de0c57335b816a28ef225342ae0dc853542e8a78 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 6 Jan 2018 13:53:42 +0200 Subject: [PATCH 5/6] Update isUpperCase.md --- snippets/isUpperCase.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/snippets/isUpperCase.md b/snippets/isUpperCase.md index 3d4c74760..116241fc2 100644 --- a/snippets/isUpperCase.md +++ b/snippets/isUpperCase.md @@ -1,16 +1,16 @@ ### isUpperCase -Checks if the provided argument contains anything else than the uppercase alphabets. If the second argument is provided to be true than numbers and other symbols are considered uppercase too. +Checks if a string is upper case. + +Convert the given string to upper case, using `String.toUpperCase()` and compare it to the original. + + ``` js -const isUpperCase = (val,symbol = false) => { - if (symbol) return val === val.toUpperCase() - else return!(/[^A-Z]/g.test(val)) -} +const isUpperCase = str => str === str.toUpperCase(); ``` + ``` js -isUpperCase('ABC'); //true -isUpperCase('ABC123@$'); //false -isUpperCase('ABC123@$',true); //true -isUpperCase('ABC123@$abcd',true); //false -isUpperCase('ABC123@$abcd'); //false +isUpperCase('ABC'); // true +isLowerCase('A3@$'); // true +isLowerCase('aB4'); // false ``` From 40568e0ccb580fe540d251993d55a4a77acfc279 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sat, 6 Jan 2018 13:53:59 +0200 Subject: [PATCH 6/6] Update isLowerCase.md --- snippets/isLowerCase.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/isLowerCase.md b/snippets/isLowerCase.md index 2e5b1305d..623ac2a2e 100644 --- a/snippets/isLowerCase.md +++ b/snippets/isLowerCase.md @@ -9,7 +9,7 @@ const isLowerCase = str => str === str.toLowerCase(); ``` ```js -isLowerCase('abc'); //true -isLowerCase('a3@$'); //false -isLowerCase('Ab4'); //false +isLowerCase('abc'); // true +isLowerCase('a3@$'); // true +isLowerCase('Ab4'); // false ```