Created
February 7, 2018 04:44
-
-
Save chadwithuhc/5128d2234ed634d22ee33ed346785074 to your computer and use it in GitHub Desktop.
JavaScript Pro Tips
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
// Challenge: Pull out the "character" value from the following URL string | |
// http://localhost:3000/characters/new?character=Art+Vandelay | |
// Using the `URL()` API, we can pull out the search params without needing to regex, split, or other wonkery | |
const params = (new URL(url)).searchParams | |
params.get('character') // Art Vandelay | |
// `URL()` will also handle uri decoding -- urls with %20, +, etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment