Skip to content

Instantly share code, notes, and snippets.

@gingerrific
Last active August 29, 2015 14:01
Show Gist options
  • Save gingerrific/a7ec29c3cad02954d300 to your computer and use it in GitHub Desktop.
Save gingerrific/a7ec29c3cad02954d300 to your computer and use it in GitHub Desktop.
// Using the same data from Mason's bonus HW: https://gist.github.com/masondesu/1eafc9e7dff1ca7666ba
// the following will still return an array like the following:
[Array[2], Array[2], undefined, undefined, Array[2], Array[2], undefined, undefined, undefined, Array[1], undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, Array[1], undefined, undefined, undefined, undefined, undefined]
var styleZ = items.map (function (item) {
if (item.style != null) {
return item.style
}
})
@gingerrific
Copy link
Author

found a really janky way to do what I wanted to do

items.reduce (function (set, item) {
    if (item.style) {
        set.push(item.style);
    } return set;
}, []).join();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment