CodePen

HTML

            
              <button onclick='GENERATE()'>GENERATE</button>
<textarea cols="30" rows="10" class="code"></textarea>

<p class='explanation'>Clicking the generate button generates random WORKING JavaScript code. Every time you click, more (working) code gets appended. 
  <br>It's 100% pseudorandom (as random as the Math.random() function). It's.. the worst thing I ever did.
<br>The box displays generated JS code.
<br>Fun fact: Statistically, it's possible that this code becomes skynet.
    <br>Fun fact #2: Statistically, it's possible that this code creates itself.
    <br>Fun fact #3: Statistically, it's possible that this code creates a 100% accurate picture of YOU.
    <br>Fun fact #4: Statistically, it's possible that this code solves all unsolved mathematical, scientifical, biological, statistical, philosophical and even more problems.
  <br> Fun fact #5: Statistically, it's more likely to generate something that makes no sense at all, and it will probably hang after about 7 clicks on the generate button.
</p>
            
          
!

CSS

            
              
            
          
!
? ?
? ?
Must be a valid URL.
+ add another resource
via CSS Lint

JS

            
              // Clicking the generate button generates WORKING Javascript code... It's 100% pseudorandom (as random as the Math.random() function). It's.. the worst thing I ever did.
// The box displays generated JS code.
// Fun fact: Statistically, it's possible that this code becomes skynet.
var allowed_characters = 
    ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-', '*', '\\', "'", '"', '=', '<', '>', '.', ',', '|', '%', '&', '^', '~', '!', '#', '$', '{', '}', '(', ')', '[', ']', ':', ';', '\n', ' '];
var code = '',
var last_added = '';

function choice(arr) {
  index = Math.floor(Math.random() * arr.length);
  return arr[index];
}

function run_code () {
  try {
    eval(code);
    return true;
  } catch (e) {
    return false;
  }
}

function add_code () {
  var amount = Math.random() * 25,
      new_code = '';
  for (var i = 0; i < amount; i += 1) {
    new_code.push(choice(allowed_characters));
  }
  code.push(new_code);
  last_added = new_code;
}

function fix_code () {
  remove_last_added();
  add_code();
}

function remove_last_added () {
  code = code.substring(0, code.length - last_added.length);
}

function GENERATE () {
  var iterations = 0;
  add_code();
  while(!run_code()) {
    iterations += 1;
    fix_code();
    if (iterations >= 10000) {
      alert('Sorry, the code hangs a little, I\'ve made sure your browser doesn\'t crash :) (the code won\'t be errorless now though :<)');
      remove_last_added();
      break;
    }
  }
  $('.code').val(code);
}
            
          
!
Must be a valid URL.
+ add another resource
via JS Hint
Loading ..................