Skip to content

Instantly share code, notes, and snippets.

@rilerez

rilerez/tinyurl.js

Created Jan 15, 2019
Embed
What would you like to do?
tinyurl
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