Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eea8ab3 commit 82e7edeCopy full SHA for 82e7ede
1 file changed
String/CheckKebabCase.js
@@ -0,0 +1,20 @@
1
+// CheckKebabCase method checks the given string is in kebab_case or not.
2
+
3
+// Problem Source & Explanation: https://en.wikipedia.org/wiki/Naming_convention_(programming)
4
5
+/**
6
+ * CheckKebabCase method returns true if the string in kebab_case, else return the false.
7
+ * @param {String} varName the name of the variable to check.
8
+ * @returns `Boolean` return true if the string is in kebab_case, else return false.
9
+ */
10
+const CheckKebabCase = (varName) => {
11
+ // firstly, check that input is a string or not.
12
+ if (typeof varName !== 'string') {
13
+ return new TypeError('Argument is not a string.')
14
+ }
15
16
+ const pat = /(\w+)-(\w)([\w-]*)/
17
+ return pat.test(varName) && !varName.includes('_')
18
+}
19
20
+module.exports = CheckKebabCase
0 commit comments