
var butter = (function($){
    var verbs = null;
    var nouns = null;

    /**
     * SHOW ME WHAT YOU GOT
     */
    function onPurposeRequest() {
        $('#verb').html(getVerbFromDictionary());
        $('#noun').html(getNounFromDictionary());
    }

    function init() {
        $('#purpose').on('click', onPurposeRequest);
    }

    function getRandomInt(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function getVerbFromDictionary() {
        var v = 'pass';

        if (verbs != null) {
            v = verbs[getRandomInt(0, verbs.length-1)];
        }

        return v;
    }

    function getNounFromDictionary() {
        var n = 'butter';

        if (nouns != null) {
            n = nouns[getRandomInt(0, verbs.length-1)];
        }

        return n;
    }

    function loadData()
    {
        $.getJSON('words.json', function(data) {
            verbs = data.verbs;
            nouns = data.nouns;
        });
    }

    /**
     * fire the plasma cannon
     */
    (function __init(){
        $(document).ready(init);

        //Load files
        loadData();
    })();
})(jQuery);

var butter = (function($){
    var verbs = null;
    var nouns = null;

    var lastVerb = null;
    var lastNoun = null;

    /**
     * SHOW ME WHAT YOU GOT
     */
    function onPurposeRequest() {
        $('#verb').html(getVerbFromDictionary());
        $('#noun').html(getNounFromDictionary());
    }

    function init() {
        $('#purpose').on('click', onPurposeRequest);
    }

    function getRandomInt(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    //Recursion for kicks.

    function getKindaRandomVerbIndex() {
        var v = getRandomInt(0, verbs.length-1);

        if (v == lastVerb) {
            v = getKindaRandomVerbIndex();
        }

        lastVerb = v;

        return v;
    }

    function getKindaRandomNounIndex() {
        var n = getRandomInt(0, nouns.length-1);

        if (n == lastNoun) {
            n = getKindaRandomNounIndex();
        }

        lastNoun = n;

        return n;
    }

    function getVerbFromDictionary() {
        var v = 'pass';

        if (verbs != null) {
            v = verbs[getKindaRandomVerbIndex()];
        }

        return v;
    }

    function getNounFromDictionary() {
        var n = 'butter';

        if (nouns != null) {
            n = nouns[getKindaRandomNounIndex()];
        }

        return n;
    }

    function loadData()
    {
        $.getJSON('words.json', function(data) {
            verbs = data.verbs;
            nouns = data.nouns;
        });
    }

    /**
     * fire the plasma cannon
     */
    (function __init(){
        $(document).ready(init);

        //Load files
        loadData();
    })();
})(jQuery);
Add a check to see if we're using the same noun or verb, and lookup a new one if true.