Skip to content

Instantly share code, notes, and snippets.

@hughrawlinson
Created February 11, 2016 11:16
Show Gist options
  • Save hughrawlinson/6ad6c42d7c64aed47993 to your computer and use it in GitHub Desktop.
Save hughrawlinson/6ad6c42d7c64aed47993 to your computer and use it in GitHub Desktop.
I love functional Javascript and the chrome developer tools.
a=Array.prototype.map.bind(document.querySelectorAll('.row>.col-lg-3'))(function(a){
return [
a.children[0].innerText,
Array.prototype.map.bind(a.children[1].children)(function(b){
var anchor = b.children[0];
return {name:anchor.innerText,href:anchor.href};
})
];
}).reduce(function(acc,el){
acc[el[0]] = el[1];
return acc;
},{});
console.table(Object.keys(a).reduce(function(acc,el){
a[el].map(function(e){
acc.push([el,e.name,e.href]);
});
return acc;
},[]),[0,1,2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment