Skip to content

Instantly share code, notes, and snippets.

@jeffharnois
Created March 21, 2014 01:19
Show Gist options
  • Save jeffharnois/9677637 to your computer and use it in GitHub Desktop.
Save jeffharnois/9677637 to your computer and use it in GitHub Desktop.
arr1 = ['T-GEO-US', 'T-GEO-CA']
arr2 = ['T-GEO-US', 'T-GEO-GA']
targetings = [arr1, arr2]
# we want only T-GEO-US to be returned
# Current:
flatTargetings = [].concat.apply [], targetings
# flatTargetings = ['T-GEO-US', 'T-GEO-CA', 'T-GEO-US', 'T-GEO-GA']
geoTargetings = _.uniq flatTargetings
# geoTargetings = ['T-GEO-US', 'T-GEO-CA', 'T-GEO-GA']
# Should be:
geoTargetings = _.intersection arr1, arr2
# geoTargetings = ['T-GEO-US']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment