Pen Settings

HTML

CSS

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

JavaScript

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

Packages

Add Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import or require. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Behavior

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.

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.

            
              <div id="content">
  <div id="simon">
    <ul>
      <li class="simonGreenOff colorButton" id="simonGreen">
      </li>
      <li class="simonRedOff colorButton" id="simonRed">
      </li>
      <li class="simonYellowOff colorButton" id="simonYellow">
      </li>
      <li class="simonBlueOff colorButton" id="simonBlue">
      </li>
    </ul>

    <div id="center">
      <div id="name">simon<span id="registered">®</span></div>
      <div id="controls">
        <div id="countCol">
          <div id="countDisplay">

          </div>
          <div class="controlLabel" id="countLabel">COUNT</div>
        </div>
        <div id="startCol">
          <div class="controlButton" id="startButton"></div>
          <div class="controlLabel" id="startText">START</div>
        </div>
        <div id="strictCol">
          <div class="strictLightOff" id="strictLight"></div>
          <div class="controlButton" id="strictButton"></div>
          <div class="controlLabel" id="strictText">STRICT</div>
        </div>
      </div>
      <div id="switch">
        <div class="offOnText" id="off">OFF</div>
        <div id="switchCasing">
          <div id="toggle"></div>
        </div>
        <div class="offOnText" id="on">ON</div>
      </div>
    </div>
  </div>
</div>
            
          
!
            
              body {
  background-image: url("http://www.homerallen.com/images/wood_texture.jpg");
}

#content {
  height: 100%;
  width: 100%;
}

#simon {
  width: 450px;
  height: 450px;
  margin: 100px auto;
  position: absolute;
  left: 0;
  right: 0;
}

#center {
  width: 50%;
  height: 50%;
  border-radius: 100%;
  -moz-border-radius: 100%;
  border: 7.5px solid black;
  background-color: #222222;
  color: white;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  user-select: none;
  -webkit-user-select: none;
  /* Chrome/Safari */
  -moz-user-select: none;
  /* Firefox */
  -ms-user-select: none;
  /* IE10+ */
}

#name {
  height: 25%;
  font-family: 'Bree Serif', serif;
  font-size: 50px;
  text-align: center;
  margin: 15px auto 0px auto;
}

#registered {
  font-size: 15px;
}

#controls {
  height: 34.5%;
  font-family: 'Fira Sans Extra Condensed', sans-serif;
  font-size: 14px;
  text-align: center;
  margin: 5px 0px 0px 0px;
}

#controls>div {
  display: inline-block;
  height: 100%;
  width: 30.5%;
  text-align: center;
  vertical-align: top;
  position: relative;
}

#countDisplay {
  background-color: #4F5440;
  height: 45.5%;
  width: 55%;
  line-height: 200%;
  font-size: 18px;
  border: 2px solid #777777;
  border-radius: 10%;
  margin: auto;
  position: absolute;
  left: 20%;
  bottom: 24px;
}

.controlButton {
  width: 100%;
  position: absolute;
  bottom: 24px;
  margin: auto;
  left: 28%;
}

.controlButton:active {
  bottom: 21px;
}

.controlLabel {
  width: 100%;
  position: absolute;
  bottom: 5%;
}

#startButton {
  background-color: #BD0018;
  border-radius: 100%;
  border: 3px solid black;
  height: 27%;
  width: 30.8%;
  margin: auto;
}

#strictLight {
  position: absolute;
  border-radius: 100%;
  height: 9%;
  width: 10.6%;
  border: 2px solid black;
  left: 41%;
  bottom: 75%;
}

.strictLightOff {
  background-color: #32050C;
}

.strictLightOn {
  background-color: #BD0018;
}

#strictButton {
  background-color: #FFEF00;
  border-radius: 100%;
  border: 3px solid black;
  height: 27%;
  width: 30.8%;
  border-radius: 100%;
  margin: auto;
}

#switch {
  text-align: center;
  font-family: 'Fira Sans Extra Condensed', sans-serif;
  font-size: 14px;
  margin: 6% 0px 0px 0px;
}

#switch>div {
  display: inline-block;
  vertical-align: middle;
}

#switchCasing {
  height: 25px;
  width: 50px;
  background-color: #777777;
}

#toggle {
  height: 100%;
  width: 50%;
  background-color: blue;
  border: 2px solid black;
  position: relative;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

.toggleOn {
  margin-left: 45%;
}

ul {
  height: 100%;
  width: 100%;
  padding: 0;
  margin: 0 auto;
  list-style-type: none;
  font-size: 0;
  text-align: center;
}

ul li {
  display: inline-block;
  vertical-align: top;
  height: 45%;
  width: 45%;
}

#simonGreen {
  border: 7.5px solid black;
  -moz-border-radius: 100% 0 0 0;
  border-radius: 100% 0 0 0;
}

.simonGreenOff {
  background-color: #008439;
}

.simonGreenOn {
  background-color: #7AF492;
}

#simonRed {
  border: 7.5px solid black;
  -moz-border-radius: 0 100% 0 0;
  border-radius: 0 100% 0 0;
}

.simonRedOff {
  background-color: #BD0018;
}

.simonRedOn {
  background-color: #FF9B9B;
}

#simonYellow {
  border: 7.5px solid black;
  -moz-border-radius: 0 0 0 100%;
  border-radius: 0 0 0 100%;
}

.simonYellowOff {
  background-color: #FFEF00;
}

.simonYellowOn {
  background-color: #FFF78E;
}

#simonBlue {
  border: 7.5px solid black;
  -moz-border-radius: 0 0 100% 0;
  border-radius: 0 0 100% 0;
}

.simonBlueOff {
  background-color: #0073AD;
}

.simonBlueOn {
  background-color: #61A4FF;
}

@media only screen and (max-device-width: 736px) and (orientation: portrait) {
  #simon {
    width: 318.75px;
    height: 318.75px;
  }
  #center {
    background-color: #333333
  }
  #name {
    font-size: 35px;
  }
  #registered {
    font-size: 10px;
  }
  #controls {
    font-size: 13px;
  }
  #countDisplay {
    font-size: 14px;
  }
  #switch {
    font-size: 13px;
  }
  #switchCasing {
    height: 20px;
    width: 40px;
  }
  #strictLight {
    bottom: 90%;
  }
}
            
          
!
            
              $(document).ready(function() {
  var deviceState = "off";
  var stepCount = 0;
  var arrSequence = [];
  var inputSequence = [];
  var strict = false;

  var simonGreen = 'data:audio/mp3;base64,//NAwAAAAAJYAUAAAP/c0Zhhsa0QV/vxJjdg1ja5Kv+X4GSASN53w1cCAGBlQP4hOJTGT/w1YHVCxcDfkf/AMBDBIORcr//5OFw0N9P//8oGgARgXKMmhr////06CDJ+9X////+z7aD/80DAWxjzEjgBnaABgaByYceMwT48EjRUAUCVl5AgOzAozDFMnD/HZTggdzDcGjAsKhIDWgKAs4q44U2Wq1q0IgNMDgCZc/Wf//RcY4BwwX25dRR//////vSD8g4Fkv/////////////zQMBSFmLmilHdmAH//WeDoxPw4CSmAgMA5dQGh+Y3VqZohyXUS/fdnCsbz87z/2SEAAqN//+iah3Aik///////eiLwiqv/////////////+ibBJgFgiIweZiIAC4wZBkw5Co3IjY3//NAwFMQ8uqMAutiudQwKBdQPZCsoUAl0ct9//CFAWlv//0SqErGeR//////95wPwDNpf/////////////9AujlAfAk4sIk2MwIQBjBDAFMAIHowsUejDOB+AIDpZRAYmuhozS1zWv3/80DAahHi7oAA7Ka42BpB2UP//qlUNTEkPf/////+qcGGFDJt//////////////qNhCoLqQBtW/MEBVCAKMTAbOF2nOVgXIiaDAMQCJtjoINix1jr1LUsEMRqX//7w6EN9b//////rf/zQMB9EprmgAD0JriqEYifl//////////////6lk0H6AH4HaAAUjgBlKwQUAXMAAB4cCLMJBSMwNQjzAKAiLVsrSYSDaHRf//0RJAjv/19/c6pJ//U3R6r///s5wRiZN////////////NAwI0SWup8AOwmuP///9RKiuAZ+SR4AFAwAd5ahCEhhQAgQXR0kEh4GA5EYgOCdDmOAEOg2p3ljhr/HUDL/7d/Ws+Sb/+rX/f//9lGRDw3hv/////////////+mKeLkAwyQhTwAED/80DAnhNy7nx482S4mkFABTApAYMBYDcwDwkjB3WaMRUJQwBQHxQAJIBLIt61af/PXveOgKyv9ktX81G////////WUxPv//////////////XIwByAF4kUWyABRCxiiMN3ABSGSZak9P/zQMCrE2rudHjsaLjpD8DZc8akMNsgi1vX9/oJAJvoz88kNMdzOaQiMMl/9jD3MZlmK6v6vV1J3IIZpf///7VMnVr9WtV///////mQjIC8bsAHBQrwwUt0YgTmeYRjTadrdnXbIJAm//NAwLgTmu50YPQmuaTSHVLRQq/jjauzUOFwAhdrJXVnub6FQVGL/+/95n//7qJgy0m/X/7f3U7da1an1vs3//////rNSQAPTFiAAJUiMLDjIPDQsw0VwJ9zJqMDA0kCzJL8aDisFqj/80DAxBSa7os+2qC68+apKRIeCtoN6v/0yVDVYXTKzf/////9riti+v////qXs1mW9/Uv//////7nwQ4QXGmsAygAQpAaZS7HQyxr4gYkgmqI4sWMHaqzkAA6ENN++fuUAmEMa39nVf/zQMDMFLLubzbZ2riqcej0QQBYTjTv/////+xNJU4fb///9FT9XRRRU/qSUl//////0x6g3gAKgskQXKzxl7QGpKWlygYcRqFVDpy5iKafDF2ovNDoiigmQPMVFUx2RUVEV2JDURgh//NAwNQUMu5YBuSiuBAIBHGhMs7P/////5UVU////////////+iqzs5QwUECOR9ChgQYsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/80DA3hVi7kxG2pq4AAAAAAAAAAAAAAAAAAAAAAAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIP/zQMDjFOr5yADBxLkAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAA//NAwOoAAAJYAAAAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAAC/A+kEAAAz';

  var simonRed = 'data:audio/mp3;base64,//MwwAAAAAJYAUAAAAwBQGBwOBQOBgB1A34DtDQYPAAoDTjIGnfIxb/j8RYt/4LgFg/M/8eMePz//8kMZzScKb//8RC//////bf3//////MwwEERwvZ8f5NQIP/zIDAmFykJFSHUAMBQMPhYIwQDnwaBwUBvEMsUBopNvzoyJEkv//MimHh0v/////0jApt////////////+okBQ//MwwDsOqpKlgdVoAYAOxQvEsGIPI1ZBTAfuMUlfC/3//6hNEP//zEVv/////+TCP/////////////WEEaiJVUBKRpg16HGSKXagm5jl//MwwEEMKpahQNtatI0/f//xV///WYi1//////1CiE/////////////74MDUwBX6RJRJgw+LgHax4NNRl9e5dr///9Qcf//6Hib///////MwwFEMIpqcAONUtP6DATv////////////vhOBW4AIzdgZA6CQwetzs44CAOziH6ekt0vP//oGbf//Q8l//////0iYQv/////////////MwwGEMWpqcIOKUtP+gfBnPgCBZsQDUjhqh/AaqMIjIP1JozTZ2b6BeP/+06jkwdO+3dlnf1n0//QN/////////////zlAEAAkpdIEA//MwwHANCpqcQOKatDLpGHnCeqHAYIV/XqlWtU5+v/C03//4zDr//////6ZLf///////////+rRL4Ns1A4l4dABeRlxhoPH7CeGBRk7u//MwwHwNQpaoeKqOtlJK6SVf+//BT//+gxH3//////MT3////////////2WZm4CQHABXvBlFILmwupABOACQwcKJGzov+gt/+1LOECCv//MwwIgNQpqUYOKatOxyKjdTTpV2NX/6Dw7///6/////////8aALgC5EKgERyqWRCITaCNHAManK+8quP///Ug8XW62+68KDpX//66f///MwwJQNepaQSOKatf5hRP////////////8LDjgAj04wIGBJwLAzPRwgeFvpxQE3F0985//xCMIhl//9CUVyb//////OJ///be/1fr////MwwJ8NypqoeKFKtv////7BJS6eQAhH1JQjhyB5xsbno2pY98tmpdll/758qD0Wp//6AuB0//////8SDor/////oYrf//////4RAEcA//MwwKgNapqYeslKti+pBD0YljhHqDhC1BtCLjcLGgEsssz0KEOztZ6p2/ymKFQ5Hb/////////////////ZymKCBgwNUAAAAAAAAAAA//MwwLMOQpp0GNqatAAAAAAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAA//MwwLsOCppwOMnKtiAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAg//MwwMMOIo3UAHiEtQAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAA//MwwMsAAAJYAAAAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAvwMdBQAANA==';

  var simonYellow = 'data:audio/mp3;base64,/+MwwAAAAAJYAUAAAP+tETMpXTjE8/9p6ozVZHD2+Jf9rlcyxCASEjmi3Ayg4DJFABknvwN8gAejA04cLZ/+RMvjrFBi4/++CACAkwBujArQiBc//yuYE4XybK6P//6aZOIIINAcC////BtqBkwJ4wNOggg/////+m9lug3///////0000PoGBOAZMKHtBaYbpgkyGBRct8YHD2Y/+MgwI8hLBIwAZ2gAJQNmIoVGDY0n8pKHbhMmGpIGIg1RNIpgJCABftjsSs46prWX41UisI7CZcNUDnEWJ5Kk+i3/r1sZE8AuAA0KELMkSKyv////////UkkQcGosR0RySLL////////4zDAZR8T6nTJ3aAB///////////+tygQ8OKAywgOXE7mB4HAlMtlYEAYeAQLAMYAj+Z1emZPjKYHhGYRgKTApA8ItYY8/+e/rTMQHY42////qMCbFYKKaP////////9MtJAOei///////////////////6TsViaByQBoJSAAURzJnJgMBo6Bpg0DJh6Ixxh5RtuGxgaN5hsLoCD/4yDAdxYr4oQA7BrZORRadDsuq9y7z0eqiPyAHJT////3MTxocS///q/v////1nRIhtJJf//////////////////ouWSVGsGCgJkZY1TgfhHcFAUYQgiKgih8YgBocZ8Ia+FgYPhMYP/jMMB5F9vmeBjrYtnIfAoA1AKksjFjuev8wshrJMEsCbPt////UYDSaP/////////uiXBZSX//////////////////9SiiXgxuA8hBgcz55wPUoDWWggwOg0HGVxCIwUYpHZwxSmZDeadOgYJlUHAkUrn4/S1q9NfTNZY0BgQQn6f///PIC5////aum3///85iBh8L2X//+j1nsv/jIMCoF0PueADrYtinfamuh6q9tKHtZm7OtEp///////VkUSwCoiBkTKgOASAt0NAzfdztASEmZI+d7eZxkbhyCoMPvo06WKbRGlyy/E3Q41AFAeCATHV///9B4JgAQJEW/////////+MwwKYaK+Z4FuKU2/8ydL///+ip/+v99SanRSRfZF6KTotuiyn///////1ssujSEhMDYDDjAITEZgRnTFFgNHNkJNi0MZJBLEDUAU6LIs8ZsuV4IHt3K9g2RakXiRJhfLCWLpxN2qsp12/2SJpIEMYELsFaJuMgeRd7f///////NRWJGop7f/////////////////5qKxxglAtE/+MgwMwY4+ZkBtHa2gNxgkaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAIAAgACAAIAAgACAAIAAgACD/4zDAwxsL7hQA007YACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAD/4yDA5QAAAlgAAAAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAAL8DGQQAADU=';

  var simonBlue = 'data:audio/mp3;base64,/+MgwAAAAAJYAUAAAP/dwzLGc0Onr/lmztZgjZRFv+/YIjZAQV9DAwBgDXLgCmn+PwoAcAav/ZsM8AYEAdJMGERR//xwMxcLhp//m7s5ZGbES///AOAFF0Gqp////pvTdDoM//////T/4yDAWxo7GjgBnaAA3pm4WiCdQ5c0DH///ygYdCS8D0CgCgZy5L0xOCoxzDg47YA6GA8wVB0wEASN1oMimvx7rHHKVKTEICyHl//+uZF8P+MMAWxiX//////6RKitjxdb///////////jIMBNFgrqsv/dkAH///+vQTEdjJiUBIBpNkWAtJcKBmYw1CYvCKlJE3PfJtpfe7+vpToxQJ4tv//6zAkQVRb//////9BAkg4Si3/////////////+oeoK6NxBPOB26zTR0NGIyGd0/+MgwE8RGvKQAOtauPefLGZkQCCQDhlTARgWmqY7z+SSERYIS3+v/mmnFm//////95kVEoUm//////////////0B8BbAAQwWlDyozUCh4GCoYSFYZkdYcMgwKAGIgALuq6L2q9y7n/r/4yDAZRHC6oQA4pq5lqcHsJQ0W31/r9RMMf//////8lBklt/////////////9VIvkCApAbCGAisCAAwHDMETjLywxZNMTlDiXwxFYMhLx4IR0LjtWcbOW0vLTIcRC8BUs1P6/2IjBaP/jIMB5EprufADrZLnG///7fN67fx41v////+3+nb//////oeAkDRLJiwDgANKaqYWwHLwBpK4c/QGxlxkIU2GPu458h3zLfLxMExguZ///OEYFAnCU3//////0Hppv////U039zWdt/+MgwIkS0u53JtqOuFL2//////6D4QQAoXkoj7QFRF0TCAENIXBc4IAmIt9yZyHrtnWRQ8iNio4exyOaj9bamEgegSCwPxgbDpj//////1VjKj/////////////9WMGOMBBQQsY2QAD/4yDAmBKq7mQG2dS4AAAAAAAAAAAAAAAAAAAAAAAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIP/jIMCoEtr2HADBxLkAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAA/+MgwLcAAAJYAAAAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAAC/AzEKAAA2';

  var audioGreen = new Howl({
    src: [simonGreen]
  });
  var audioRed = new Howl({
    src: [simonRed]
  });
  var audioYellow = new Howl({
    src: [simonYellow]
  });
  var audioBlue = new Howl({
    src: [simonBlue]
  });

  function newGame() {
    resetGame();
    calculateNextInSequence();
    presentSequence(arrSequence);
  }

  function switchDeviceState() {
    if (deviceState === "off") {
      deviceState = "on";
    } else if (deviceState === "on") {
      disableButtons();
      $("#strictLight").removeClass("strictLightOn");
      strict = false;
      deviceState = "off";
      updateDisplay("");
    }
  }

  function toggleStrictMode() {
    if (strict === false) {
      strict = true;
    } else if (strict === true) {
      strict = false;
    }
  }

  function disableButtons() {
    $(".colorButton").off();

    $("#simonGreen").on("mousedown touchstart", function() {}).on("mouseup touchend", function() {});
    $("#simonRed").on("mousedown touchstart", function() {}).on("mouseup touchend", function() {});
    $("#simonYellow").on("mousedown touchstart", function() {}).on("mouseup touchend", function() {});
    $("#simonBlue").on("mousedown touchstart", function() {}).on("mouseup touchend", function() {});
  }

  function enableButtons() {
    $(".colorButton").on("click", processButtonClick);

    var isTouchSupported = "ontouchend" in document;
    var myDown = isTouchSupported ? "touchstart" : "mousedown";
    var myUp = isTouchSupported ? "touchend" : "mouseup";

    $("#simonGreen").on(myDown, function() {
      audioGreen.play();
      $(this).addClass('simonGreenOn');
    }).on("mouseup touchend", function() {
      $(this).removeClass('simonGreenOn');
    });

    $("#simonRed").on(myDown, function() {
      audioRed.play();
      $(this).addClass('simonRedOn');
    }).on("mouseup touchend", function() {
      $(this).removeClass('simonRedOn');
    });

    $("#simonYellow").on(myDown, function() {
      audioYellow.play();
      $(this).addClass('simonYellowOn');
    }).on("mouseup touchend", function() {
      $(this).removeClass('simonYellowOn');
    });

    $("#simonBlue").on(myDown, function() {
      audioBlue.play();
      $(this).addClass('simonBlueOn');
    }).on("mouseup touchend", function() {
      $(this).removeClass('simonBlueOn');
    });
  }

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

  function resetGame() {
    stepCount = 0;
    arrSequence = [];
    inputSequence = [];
  }

  function calculateNextInSequence() {
    arrSequence.push(getRandomIntInclusive(1, 4));
    stepCount++;
  }

  function updateDisplay(clearOrStep) {
    $("#countDisplay").text(clearOrStep);
  }

  function presentSequence(sequence) {
    disableButtons();

    updateDisplay(stepCount);

    for (var i = 0; i < stepCount; i++) {
      (function(ind, sequence) {
        setTimeout(function() {
          if (deviceState === "on") {
            lightButton(sequence[ind]);
          }
        }, 1000 * (ind + 1));
      })(i, sequence);
    }

    setTimeout(function() {
      enableButtons();
    }, 750 * stepCount);

    function lightButton(numButton) {
      var selector;
      var onClass;
      var audio;

      switch (numButton) {
        case 1:
          selector = "#" + "simonGreen";
          onClass = "simonGreenOn";
          audio = audioGreen;
          break;
        case 2:
          selector = "#" + "simonRed";
          onClass = "simonRedOn";
          audio = audioRed;
          break;
        case 3:
          selector = "#" + "simonYellow";
          onClass = "simonYellowOn";
          audio = audioYellow;
          break;
        case 4:
          selector = "#" + "simonBlue";
          onClass = "simonBlueOn";
          audio = audioBlue;
          break;
        default:
          break;
      }

      audio.play();

      window.setTimeout(function() {
        $(selector).toggleClass(onClass);
      }, 200);
      window.setTimeout(function() {
        $(selector).toggleClass(onClass);
      }, 500);
    }
  }

  function processButtonClick(e) {
    var buttonId;

    if (deviceState === "off") {
      return;
    }

    switch (e.currentTarget.id) {
      case "simonGreen":
        buttonId = 1;
        break;
      case "simonRed":
        buttonId = 2;
        break;
      case "simonYellow":
        buttonId = 3;
        break;
      case "simonBlue":
        buttonId = 4;
        break;
      default:
        break;
    }

    inputSequence.push(buttonId);

    if (validateInput() === false && strict === true) {
      invalidInput();
      setTimeout(function() {
        newGame();
      }, 2000);
    } else if (validateInput() === false && strict === false) {
      invalidInput();
      inputSequence = [];
      setTimeout(function() {
        presentSequence(arrSequence);
      }, 2000);
    } else if (validateInput() && inputSequence.length === arrSequence.length && inputSequence.length === 20) {
      updateDisplay("WIN!");
      setTimeout(function() {
        newGame();
      }, 3000);
    } else if (validateInput() && inputSequence.length === arrSequence.length) {
      disableButtons();
      calculateNextInSequence();
      inputSequence = [];
      presentSequence(arrSequence);
    }

    function invalidInput() {
      disableButtons();
      updateDisplay("! !");
    }

    function validateInput() {
      if (arrSequence[inputSequence.length - 1] === inputSequence[inputSequence.length - 1]) {
        return true;
      } else {
        return false;
      }
    }
  }

  $("#switchCasing").click(function() {
    $("#toggle").toggleClass("toggleOn");
    switchDeviceState();
  });

  $("#startButton").click(function() {
    if (deviceState === "on") {
      newGame();
    }
  });

  $("#strictButton").click(function() {
    if (deviceState === "on") {
      $("#strictLight").toggleClass("strictLightOn");
      toggleStrictMode();
    }
  });

  disableButtons();
});
            
          
!
999px

Console