From 77c3a9eac8f8628e60938512e4a3ce83b48b6a26 Mon Sep 17 00:00:00 2001 From: Suryapratap Singh Date: Fri, 20 Aug 2021 01:12:34 +0530 Subject: [PATCH 1/6] add CheckCamelCase method --- String/CheckCamelCase.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 String/CheckCamelCase.js diff --git a/String/CheckCamelCase.js b/String/CheckCamelCase.js new file mode 100644 index 000000000..a53bd8857 --- /dev/null +++ b/String/CheckCamelCase.js @@ -0,0 +1,20 @@ +// CheckCamelCase method checks the given string is in camelCase or not. + +// Problem Source & Explanation: https://en.wikipedia.org/wiki/Camel_case + +/** + * CheckCamelCase method returns true if the string in camelCase, else return the false. + * @param {String} varName the name of the variable to check. + * @returns `Boolean` return true if the string is in camelCase, else return false. + */ +const CheckCamelCase = (varName) => { + // firstly, check that input is a string or not. + if (typeof varName !== 'string') { + return 'Not string(s)' + } + + const pat = /^[a-z][A-Za-z]*$/ + return pat.test(varName) +} + +module.exports = CheckCamelCase From e48f5e2192bb5781bc48b8f2f7f02ae9f7065148 Mon Sep 17 00:00:00 2001 From: Suryapratap Singh Date: Fri, 20 Aug 2021 01:18:47 +0530 Subject: [PATCH 2/6] add CheckPascalCase method --- String/CheckPascalCase.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 String/CheckPascalCase.js diff --git a/String/CheckPascalCase.js b/String/CheckPascalCase.js new file mode 100644 index 000000000..3af6d9276 --- /dev/null +++ b/String/CheckPascalCase.js @@ -0,0 +1,20 @@ +// CheckPascalCase method checks the given string is in PascalCase or not. + +// Problem Source & Explanation: https://www.theserverside.com/definition/Pascal-case + +/** + * CheckPascalCase method returns true if the string in PascalCase, else return the false. + * @param {String} VarName the name of the variable to check. + * @returns `Boolean` return true if the string is in PascalCase, else return false. + */ +const CheckPascalCase = (VarName) => { + // firstly, check that input is a string or not. + if (typeof VarName !== 'string') { + return 'Not string(s)' + } + + const pat = /^[A-Z][A-Za-z]*$/ + return pat.test(VarName) +} + +module.exports = CheckPascalCase From 8722d52980a9705c082b1907727a225929bf6248 Mon Sep 17 00:00:00 2001 From: SURYAPRATAP SINGH SURYAVANSHI <67123991+suryapratapsinghsuryavanshi@users.noreply.github.com> Date: Fri, 20 Aug 2021 13:17:48 +0530 Subject: [PATCH 3/6] Update String/CheckCamelCase.js Co-authored-by: Rak Laptudirm --- String/CheckCamelCase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/CheckCamelCase.js b/String/CheckCamelCase.js index a53bd8857..26761a058 100644 --- a/String/CheckCamelCase.js +++ b/String/CheckCamelCase.js @@ -10,7 +10,7 @@ const CheckCamelCase = (varName) => { // firstly, check that input is a string or not. if (typeof varName !== 'string') { - return 'Not string(s)' + return new TypeError("Argument is not a string.") } const pat = /^[a-z][A-Za-z]*$/ From cddfc342b792d80bba5585dc9e9b07107dff8971 Mon Sep 17 00:00:00 2001 From: SURYAPRATAP SINGH SURYAVANSHI <67123991+suryapratapsinghsuryavanshi@users.noreply.github.com> Date: Fri, 20 Aug 2021 13:17:59 +0530 Subject: [PATCH 4/6] Update String/CheckPascalCase.js Co-authored-by: Rak Laptudirm --- String/CheckPascalCase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/CheckPascalCase.js b/String/CheckPascalCase.js index 3af6d9276..4e557b946 100644 --- a/String/CheckPascalCase.js +++ b/String/CheckPascalCase.js @@ -10,7 +10,7 @@ const CheckPascalCase = (VarName) => { // firstly, check that input is a string or not. if (typeof VarName !== 'string') { - return 'Not string(s)' + return new TypeError("Argument is not a string.") } const pat = /^[A-Z][A-Za-z]*$/ From 8ef1677f816a0c08c87871ec581328db5560783b Mon Sep 17 00:00:00 2001 From: Suryapratap Singh Date: Fri, 20 Aug 2021 13:24:27 +0530 Subject: [PATCH 5/6] re-formatted CheckCamelCalse by standard.js after updating error. --- String/CheckCamelCase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/CheckCamelCase.js b/String/CheckCamelCase.js index 26761a058..d15a35663 100644 --- a/String/CheckCamelCase.js +++ b/String/CheckCamelCase.js @@ -10,7 +10,7 @@ const CheckCamelCase = (varName) => { // firstly, check that input is a string or not. if (typeof varName !== 'string') { - return new TypeError("Argument is not a string.") + return new TypeError('Argument is not a string.') } const pat = /^[a-z][A-Za-z]*$/ From 0ea955b06c3751289b45bef9645d088747b7a762 Mon Sep 17 00:00:00 2001 From: Suryapratap Singh Date: Fri, 20 Aug 2021 13:25:38 +0530 Subject: [PATCH 6/6] re-formatted CheckPascalCase by standard.js after updating error. --- String/CheckPascalCase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/CheckPascalCase.js b/String/CheckPascalCase.js index 4e557b946..6babce5f0 100644 --- a/String/CheckPascalCase.js +++ b/String/CheckPascalCase.js @@ -10,7 +10,7 @@ const CheckPascalCase = (VarName) => { // firstly, check that input is a string or not. if (typeof VarName !== 'string') { - return new TypeError("Argument is not a string.") + return new TypeError('Argument is not a string.') } const pat = /^[A-Z][A-Za-z]*$/