Skip to content

Instantly share code, notes, and snippets.

@narennaik
Last active June 29, 2021 05:40
Show Gist options
  • Save narennaik/613db47700d005d26899a5a888c212e2 to your computer and use it in GitHub Desktop.
Save narennaik/613db47700d005d26899a5a888c212e2 to your computer and use it in GitHub Desktop.
using .map multiple times
const getDomainName = (item) => item.details.name;
const getProtocol = (item) => (item.details.valid ? 'https' : 'http');
const getUrl = (item) => `${getProtocol(item)}://${getDomainName(item)}`;
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter
const addCallbackParameter = (url) => `${url}?callback=true`;
const urlList = domainList.map(getUrl).map(addCallbackParameter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment