mikeb
mikeb

Reputation: 727

Grasping the concept behind a certain javascript functionality

I found this script on the Internet, and i would like very much to understand it.I know i may get negative votes, but i really would like some prospect about the way this functionality works in estimating the current world population, especially with the values chosen in the scripts and the reason behind each of these values. I'd appreciate any help please.

<body>
    <script type="text/javascript">
        function maind() {
            startdate = new Date()
            now(startdate.getYear(), startdate.getMonth(), startdate.getDate(), startdate.getHours(), startdate.getMinutes(), startdate.getSeconds())
        }

        function ChangeValue(number, pv) {
            numberstring = ""
            var j = 0
            var i = 0
            while (number > 1) {

                numberstring = (Math.round(number - 0.5) % 10) + numberstring
                number = number / 10
                j++
                if (number > 1 && j == 3) {
                    numberstring = "," + numberstring
                    j = 0
                }
                i++
            }

            numberstring = numberstring

            if (pv == 1) {
                document.getElementById("worldpop").innerHTML = numberstring
            }
        }

        function now(year, month, date, hours, minutes, seconds) {
            startdatum = new Date(year, month, date, hours, minutes, seconds)

            var now = 5600000000.0
            var now2 = 5690000000.0
            var groeipercentage = (now2 - now) / now * 100
            var groeiperseconde = (now * (groeipercentage / 100)) / 365.0 / 24.0 / 60.0 / 60.0
            nu = new Date()
            schuldstartdatum = new Date(96, 1, 1)
            secondenoppagina = (nu.getTime() - startdatum.getTime()) / 1000
            totaleschuld = (nu.getTime() - schuldstartdatum.getTime()) / 1000 * groeiperseconde + now
            ChangeValue(totaleschuld, 1);


            timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours(),startdatum.getMinutes(),startdatum.getSeconds())", 200)
        }

        window.onload = maind
    </script>

    Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>.
</body>

Upvotes: -1

Views: 62

Answers (1)

Li0liQ
Li0liQ

Reputation: 11264

The code says something like that:
The world population on Jan 1st, 1996 was 5600000000. Next year, presumably, Jan 1st, 1997, it was 5690000000. Based on that data the code tries to extrapolate population growth till present time, assuming 5690000000 - 5600000000 as a yearly population increment.

Upvotes: 2

Related Questions