Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Goodreads Book Title, Author Name Extractor: http://denizkumsal.com/programming/trifecta-filter-map-reduce/
console.log(
Array.from(document.querySelectorAll(".bookTitle, .authorName"))
.filter((entry) => entry.attributes.itemprop)
.map((entry) => entry.innerText.replace(/\s\(.*?\)\s?/, ""))
.reduce(
(result, entry, index, list) =>
index % 2 == 0 ? result.concat(`${list[index]}, ${list[index + 1]}`) : result,
[]
)
.join("\n")
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment