I have an array of strings:
var arr = [
{str: 'abc'},
{str: 'def'},
{str: 'abc'},
{str: 'ghi'},
{str: 'abc'},
{str: 'def'},
];
I am searching for a smart way to add a boolean attribute unique to the objects whether str is unique:
var arr = [
{str: 'abc', unique: false},
{str: 'def', unique: false},
{str: 'abc', unique: false},
{str: 'ghi', unique: true},
{str: 'abc', unique: false},
{str: 'def', unique: false},
];
My solution contains three _.each() loops and it looks terrible... Solutions with lodash preferred.