← Back to challenges

Retrieve the Subreddit

JavaScriptHardstringsregex

Instructions

Create a function to extract the name of the subreddit from its URL.

Examples

subReddit("https://www.reddit.com/r/funny/") ➞ "funny"

subReddit("https://www.reddit.com/r/relationships/") ➞ "relationships"

subReddit("https://www.reddit.com/r/mildlyinteresting/") ➞ "mildlyinteresting"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Does the Object Contain a Given Key?