Skip to content

Instantly share code, notes, and snippets.

@nlively
Created June 14, 2013 20:04

Revisions

  1. Noah Lively created this gist Jun 14, 2013.
    51 changes: 51 additions & 0 deletions function_tests.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    <html>


    <body>


    <a href="javascript:switchDeveloper()">Switch developer</a>

    <div id="dev-name"></div>


    <script>

    var developers = [
    'Nathan',
    'Noah',
    'Joel',
    'Connor',
    'Brian'
    ];

    var currentDev = 0;


    function getCurrentDeveloper() {
    return developers[currentDev];
    }

    function updateDeveloperDisplay() {
    var el = document.getElementById('dev-name');
    el.innerHTML = getCurrentDeveloper() ;
    }

    function switchDeveloper() {
    currentDev++;
    if (currentDev >= developers.length) {
    currentDev = 0;
    }

    updateDeveloperDisplay();

    }


    updateDeveloperDisplay();

    </script>

    </body>

    </html>