Skip to content

Instantly share code, notes, and snippets.

@joemaddalone
Created March 22, 2014 16:46
Show Gist options
  • Save joemaddalone/9710219 to your computer and use it in GitHub Desktop.
Save joemaddalone/9710219 to your computer and use it in GitHub Desktop.
find unique abbreviations from array... did not end up needing or completing this, but might be useful later
function abbevify(items,targetLength,pos,obj){
var obj = obj || {},
pos = pos || 1,
arr = items.slice(0),
t = arr[0].substring(0, pos)
if(!obj[t]){
obj[t] = arr.shift();
pos=1
}
else {
pos++
}
return (arr.length>0) ? abbevify(arr, targetLength,pos, obj) : obj
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment