Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ServiceNow JavaScript Helper

## String Helper

- `toSlug("Hello World!")` → `"hello-world"`
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Converts string to lowercase, removes symbols, replaces spaces with dashes
function toSlug(text) {
let str = text.toLowerCase();
str = str.replace(/[^a-z0-9_\s-]/g, "");
str = str.replace(/[\s-]+/g, " ");
str = str.replace(/[\s_]/g, "-");
return str;
};
Loading