Hacker News new | past | comments | ask | show | jobs | submit login

Average age is around 39

  var ages = [],
      sum = 0;
  $('tr').each(function(a,b) {
      var age = $(b).find('td:nth-child(7)').text();
      if (age !== '') {
          ages.push(age);
          sum += parseInt(age);
      }
  });
  console.log(sum / ages.length);
Returns 39.10679611650485



And most were White males.

  Blacks: 190 (36.89%)
  White: 230 (44.66%)
  Hispanics: 92 (17.86%)
  Other: 2 (0.39%)
  Total: 515


No need to store a list of ages. A simple counter should suffice.


Or just count the number of <tr> elements and subtract one to account for the table header. That's what I did to find the average race.

  $('tr').length-1




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: