Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

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

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


                <h1><a href="">The Monty Hall Problem</a></h1>

<div class="main">
  <div class="door blue"></div>
  <div class="door green"></div>
  <div class="door red"></div>

<p class="debug"></p>

<div id="controls">
  <button id="reset">RESET</button>

<div id="dialog">
  <p class="dialog-message"></p>

<h2>Generating Reports</h2>
<p>In GA:</p>
  <li>Events -> Top Events</li>
  <li>Primary Dimension: Event Category</li>
  <li>Secondary Dimension: Event Action</li>


                .door {
  height: 10em;
  width: 4em;
  background: #333;
  margin: 0px 5px;
  color: white;
  &.blue {
    background: blue;
  &.green {
    background: green;
  &.red {
    background: red;
  &.removed {
    visibility: hidden;


                $(function() {

var doorgame = (function() {

  var doorgame = {
    clicks: 0,
    firstPick: null,
    init: function() {
    reset: function() {
      this.clicks = 0;
      this.firstPick = null;
      this.showDialogue('Behind one of these doors is a grand prize! Pick one to continue.');
    delegateEvents: function() {
      $('.main').on('click', '.door', function() {
      $('#reset').click(function() {
    showDialogue: function(text) {
    pickWinner: function() {
      var $door = this.getRandomDoor();
      $('.door').data('winner', false);
      $'winner', true);
    chooseDoor: function($pick) {
      if (this.clicks === 0) {
        this.firstPick = $pick.index();
      } else if (this.clicks === 1) {
        var isWinner = $'winner');
        var didSwitch = ($pick.index() != this.firstPick);
        if (isWinner) {
        } else {
        this.track(didSwitch, isWinner);
    removeDoor: function($pick) {
      var $remainingDoors = $('.door').not($pick);
      var i = Math.floor(Math.random() * $remainingDoors.length);

      while ($($remainingDoors[i]).data('winner') === true) {
        i = Math.floor(Math.random() * $remainingDoors.length);

      this.showDialogue('Alright, we\'ve removed a door that is NOT the winner. Would you like to pick again?');
    getRandomDoor: function() {
      var i = Math.floor(Math.random() * $('.door').length);
      var $door = $('.door:eq(' + i + ')');
      return $door;
    win: function(didSwitch) {
      this.showDialogue('Correct! You\'ve won the prize!');
    lose: function(didSwitch) {
      this.showDialogue('ERRRRR Wrong!');
    track: function(didSwitch, isWinner) {
      var action = (didSwitch ? 'Switched' : 'Stayed');
      var label = (isWinner ? 'Win' : 'Lose'); 
      var value = (isWinner ? 1 : 0);
      ga('send', {
        hitType: 'event',
        eventCategory: 'DoorPick',
        eventAction: action,
        eventLabel: label,
        eventValue: value
  return doorgame;

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-28026409-4', 'auto');
ga('send', 'pageview');