Created
March 29, 2018 18:25
-
-
Save ghassanmas/e776a66c493c9242111ef23990d0fa6d to your computer and use it in GitHub Desktop.
Total street length
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
(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`) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Go to https://www.cia.gov/library/publications/the-world-factbook/fields/2085.html , then open the console and write the above code