Skip to content

Instantly share code, notes, and snippets.

@ghassanmas
Created March 29, 2018 18:25
Show Gist options
  • Save ghassanmas/e776a66c493c9242111ef23990d0fa6d to your computer and use it in GitHub Desktop.
Save ghassanmas/e776a66c493c9242111ef23990d0fa6d to your computer and use it in GitHub Desktop.
Total street length
(function() {
listnodes = document.getElementsByClassName("fieldData");
count = 0;
for (var i = 0; i < listnodes.length; i++) {
if (listnodes[i].innerHTML.match(/[0-9]+,[0-9]+|[0-9]+/)) {
str = listnodes[i].innerHTML.match(/[0-9]+,[0-9]+|[0-9]+/)[0]
} else {
continue;
}
if (str.indexOf(',') != -1) {
count = count + Number(str.replace(',', ''));
} else {
count = count + Number(str);
}
}
console.log(`total length = ${count / 1000000} million km`)
})();
@ghassanmas
Copy link
Author

Go to https://www.cia.gov/library/publications/the-world-factbook/fields/2085.html , then open the console and write the above code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment