Last active
January 21, 2016 08:24
-
-
Save ktaragorn/229cf6aabea0ee0b56e8 to your computer and use it in GitHub Desktop.
Calculate average rent of SG HDB houses from https://services2.hdb.gov.sg/webapp/BR12AWRentalEnquiry/BR12PResult.jsp
This file contains hidden or 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 rows = $("table.paginated tbody tr").filter(function(i, row){ return $(row).find("td:nth-child(5)").text() == "3-Rm";}); | |
var rents = $.map(rows, function(row) {return parseInt($(row).find("td:nth-child(6)").text())}) | |
var sum = rents.reduce(function(a, b) { return a + b; }); | |
// Average | |
sum/rents.length | |
// Max | |
Math.max(...rents) | |
// Min | |
Math.min(...rents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Search for records and tehn run this code in developer console. Change 3-Rm as per your requirement