Created
January 15, 2019 03:07
-
-
Save rileylev/c26e2f4bb63816a45ddf60b1b8bba89f to your computer and use it in GitHub Desktop.
tinyurl
This file contains hidden or 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
var tinyurl = "http://tinyurl.com/" | |
var urls = [] | |
var encode = function(longUrl){ | |
urls.push(longUrl) | |
return tinyurl+(urls.length-1) | |
}; | |
var decode = function(shortUrl){ | |
var index = Number(shortUrl.substring(tinyurl.length)) | |
return urls[index] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment