Created
May 30, 2014 18:04
-
-
Save barce/4f31142aaff493cb433e to your computer and use it in GitHub Desktop.
load jquery in console and get average age from a table
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
var jq = document.createElement('script'); | |
jq.src = "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
// ... give time for script to load, then type. | |
jQuery.noConflict(); | |
// get average age from this table: http://www.tdcj.state.tx.us/death_row/dr_executed_offenders.html | |
var ages = [], | |
sum = 0; | |
jQuery('tr').each(function(a,b) { | |
var age = jQuery(b).find('td:nth-child(7)').text(); | |
if (age !== '') { | |
ages.push(age); | |
sum += parseInt(age); | |
} | |
}); | |
console.log(sum / ages.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment