Skip to content

Instantly share code, notes, and snippets.

@icodesido
Created November 2, 2016 19:47
Show Gist options
  • Save icodesido/1edd289052b00bf766eab389691c8c14 to your computer and use it in GitHub Desktop.
Save icodesido/1edd289052b00bf766eab389691c8c14 to your computer and use it in GitHub Desktop.
Filter homogeneous array
let filterHomogenous = a => a.filter(b => b.length > 0 && b.every(e => typeof e == typeof b[0]));
var filterHomogenous = function (a) {
return a.filter(function (b) {
if(b.length > 0) {
return b.every(function (e) {
return typeof e === typeof b[0];
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment