Closed zoepage closed 9 years ago
@gr2m could you verify this or is this "a feature"? :)
Good catch! Yes, this is a bug!
initials([['Moe Minutes', 'Moe Min'])
// returns ["MMi", "MMi"]
// should return sth like ["MoM", "MMi"]
I think this is rather an edge case, so it's not a top priority to fix, but something nice for the backlog.
It breaks here:https://github.com/gr2m/initials/blob/gh-pages/initials.js#L176
splice
changes the array dynamically in the for-loop.
possible solution:
possibleInitials[i] = undefined
and possibleInitials = possibleInitials.filter(Boolean)
breaks 13 tests.
closing in favor of https://github.com/gr2m/initials/issues/14
A great idea @gr2m :)
For different names same initials appear. We need not just compare the Strings, but also the length of the name.
// scheme
['Moe Minutes', 'Moe Min'] -> ['MMi', 'MMi']
// test
Start:
function initialsForMultipleNames (names, options)