Last active
October 7, 2021 16:32
-
-
Save ChrisVilches/cced83ae2ac31be5d095debd3ce88e1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// normalizeTitle :: String -> String | |
const normalizeTitle = rawTitle => { | |
const parts = rawTitle.split(" - "); | |
const right = parts[1].toLowerCase().replace(/\s/g, "_").replace(/[^a-z_0-9]+/g, ""); | |
return `${parts[0]}-${right}`; | |
} | |
const rawTitle = document.getElementById("problem-name").innerHTML; | |
normalizeTitle(rawTitle); | |
// Example | |
// input: EASYPROB - A Very Easy Problem! | |
// output: EASYPROB-a_very_easy_problem | |
// Useful for getting a name that can be used in a code file. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment