startv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource
via CSS Lint

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource
via JS Hint

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Want a Run Button?

If active, the preview will update automatically when you change code.

HTML

            
              Joe Miller Iterations: <input id="Iterations" value="" size="5" /> <input type="button" value="Generate" onclick="JoeMillerGenerator();" />
<br />
<div id="Miller"></div>
            
          
!

CSS

            
              
            
          
!

JS

            
              var theOnlyRealName = "Joe Miller";
var redditCircleJerk = ["Joe", "Miller", "Please don't call me"]

    function JoeMillerGenerator(){
        var iterations = document.getElementById("Iterations").value;

        if(iterations=="Joe Miller" || parseInt(iterations,10)){
            
            if(iterations=="Joe Miller"){
                iterations = 100 + Math.floor(Math.random()*1000);
            }
            
            if(iterations > 10000){ //Call stack limit
                document.getElementById("Miller").innerHTML = "You can't handle that much Joe Miller";
               return "";
            }
            
            document.getElementById("Miller").innerHTML = getTheMightyName(iterations);
            
        }else{
               document.getElementById("Miller").innerHTML = iterations+" is not a valid Joe Miller number";
        }
        
    }

    function getTheMightyName(iterations) {

        if (iterations == 1) {
            return theOnlyRealName;
        } else if (iterations % 2 == 0) {
            return redditCircleJerk[0] + " \"" + getTheMightyName(iterations - 1) + "\" " + redditCircleJerk[1];
        } else {
            return redditCircleJerk[0] + " \'" + redditCircleJerk[2] + " " + getTheMightyName(iterations - 1) + "\' " + redditCircleJerk[1];
        }
        
    }
            
          
!
999px
Loading ..................

Console