Last active
March 17, 2021 11:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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