Skip to content

Instantly share code, notes, and snippets.

@simonschwartz
Last active May 19, 2019 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonschwartz/b3c90bb9d7788f8fc761fc9337fd6fbe to your computer and use it in GitHub Desktop.
Save simonschwartz/b3c90bb9d7788f8fc761fc9337fd6fbe to your computer and use it in GitHub Desktop.
const createURL = baseURL => {
const protocol = "https";
// we now return a function, that accepts a 'path' as an argument
return path => {
return `${protocol}://${baseURL}/${path}`;
};
};
// we create a new functions with the baseURL value in it's closure scope
const createSiteURL = createURL("mysite.com");
const createCareersURL = createURL("mysite-careers.com");
// create URLs for our main site
const homeURL = createSiteURL("");
const loginURL = createSiteURL("login");
const productsURL = createSiteURL("products");
const contactURL = createSiteURL("contact-us");
// create URLs for our career site
const careersHomeURL = createCareersURL("");
const careersLoginURL = createCareersURL("login");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment