i'm developing in Javascript and i created folders array that contain objects:
folders = [folder1, folder2, folder3...]
Every object have some properties, one of this is docs that is an array of objects:
docs = [doc1, doc2, doc3...]
...and every object is like this:
doc1.title = 'foo'
doc1.desc = 'bar'
doc1.attr = {new: _.random(0, 1) > 0.5, read: _.random(0, 1) > 0.5}
...
I would like to create a function that extract only docs that have attr = {new: true, read: false}.
I tried some underscore method such as _.each, _.sample, _.find and _.findWhere, but i can't figure out how to get from the main array a sample that contains docs with that attr properties.
Any idea?
.find()? Wouldn't a regular loop do the work?newwithout quotes as a key of object. use"new"instead.