Created
September 20, 2019 22:17
-
-
Save rickyhaswifi/a390301dea3b6c83cb3ffd9bd3b90d43 to your computer and use it in GitHub Desktop.
Extract ID from user input in JS
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
const youtubeID = (link) => link.slice(link.lastIndexOf('=')+1); | |
console.log(youtubeID('https://www.youtube.com/watch?v=N65RvNkZFGE')); | |
const shortLink = (short) => short.slice(short.lastIndexOf('e/')+2); | |
console.log(shortLink('https://youtu.be/N65RvNkZFGE')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment