Skip to content

Instantly share code, notes, and snippets.

@john-doherty
Last active March 17, 2021 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-doherty/320f9d431681eeb8ce24577f30d232d2 to your computer and use it in GitHub Desktop.
Save john-doherty/320f9d431681eeb8ce24577f30d232d2 to your computer and use it in GitHub Desktop.
Calculate the average number of words used to describe Y Combinator startup
// 1) visit yclist.com
// 2) open the browser console
// 3) run the following
// get all table rows
var rows = Array.prototype.slice.call(document.querySelectorAll('#companies tbody tr'));
// extract descriptions (use lastChild to skip aquired etc)
var descriptions = rows.map(function (row) { return row.cells[5].lastChild.textContent.trim(); });
// break each description into words
var wordCounts = descriptions.map(function (desc) { return desc.split(' ').length });
// workout the average words
var avgWords = wordCounts.map(function (x, i, arr) { return x / arr.length }).reduce(function (a, b) { return a + b });
// round up and write to console
Math.ceil(avgWords);
// uncomment below to write out the descriptions
// descriptions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment