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

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.

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

              
                <div id="container">
  <div id="question">___</div>
  <div id="buttonSection">
    <div id="yesNo">
      <div class="button" onclick="Yes()">Yes</div>
      <div class="button" onclick="No()">No</div>
    </div>
    <div id="text" style="display:none">
      <input type="text" id="answer" />
      <div class="button" onclick="Answer()">Submit</div>
    </div>
  </div>
</div>
<a id="credit" href="https://skidsdev.xyz">Created by Dylan Renwick</a>
              
            
!

CSS

              
                body {
  margin: 0;
  overflow: hidden;
  font-family: helvetica, arial;
}

#question {
  display: block;
  margin: 0 auto;
  font-size: 48px;
  font-weight: bold;
  width: 600px;
  text-align: center;
  margin-top: 20%;
  margin-bottom: 10%;
}

#buttonSection {
  display: block;
  margin: 0 auto;
  font-size: 24px;
  font-weight: bold;
  width: 600px;
  text-align: center;
}

.button {
  width: 100px;
  display: inline-block;
  background: #ddd;
  margin: 0 20px;
  height: 30px;
  padding: 10px;
  border: 3px solid black;
  border-radius: 10px;
  cursor: pointer;
}

#answer {
  font-size: 24px;
  height: 30px;
  border-radius: 10px;
}

#credit {
  position: absolute;
  top: 0;
  left: 0;
  text-decoration: none;
  font-weight: bold;
}
              
            
!

JS

              
                class Node {
  constructor(value, n1, n2) {
    if (n1 || n2) this.nodes = [n1, n2];
    else this.nodes = [];
    this.value = value;
  }
  
  replace(val, newNode) {
		if (this.nodes.length == 0) return false;
		if (this.nodes[0] !== null && this.nodes[0].value == val) {
			this.nodes[0] = newNode;
			return true;
    }
		if (this.nodes[1] !== null && this.nodes[1].value == val) {
			this.nodes[1] = newNode;
			return true;
    }
		if (this.nodes[0] !== null) {
			if (this.nodes[0].replace(val, newNode)) return true;
			if (this.nodes[1] !== null) return self.nodes[1].replace(val, newNode);
    }
  }
}

var node = new Node("a Pangolin", null, null);
var n = node;
var ansCallback = null;

window.addEventListener('load', () => {
  document.getElementById("container").style.width = window.innerWidth;
  document.getElementById("container").style.height = window.innerHeight;
  Play();
});

function Play() {
  noInput();
  print("OK, please think of an object, person, item, animal. Think of <i>something</i>");
  setTimeout(() => {
    Round(node, PlayCB);
  }, 3500);
}
             
function PlayCB(result) {
  if (result > 1) {
    if (result === 2) print("Good. That was soooo easy.");
    End();
  } else Round(n.nodes[result], PlayCB);
}

function Round(n, cb) {
	if (n.nodes.length == 0) {
		print("Is it " + n.value);
		readBool((response) => {
      if (response) cb(2);
      else {
        print("Oh. Well you win then -- What were you thinking of?");
        readText((answer) => {
          print(`Please give me a question about ${answer}, so I can tell the difference between ${answer} and ${n.value}`);
          readText((question) => {
            print(`What is the answer for ${answer}?`);
            readBool((ans) => {
              noInput();
              print("Thanks");
              if (ans === true) {
                newNode = new Node(question, new Node(answer, null, null), n);
              } else {
                newNode = new Node(question, n, new Node(answer, null, null));
              }
              if (node.value == n.value) node = newNode;
              else node.replace(n.value, newNode);
              setTimeout(() => cb(3), 2500);
            });
          });
        });
      }
    });
  } else {
		print(n.value);
    readBool((response) => {
      if (response) cb(0);
      else cb(1);
    });
  }
}

function End() {
  print("Would you like to play again?");
  readBool((v) => {
    if (v) Play();
    else print("Goodbye!");
  });
}

function noInput() {
  document.getElementById("yesNo").style.display = "none";
  document.getElementById("text").style.display = "none";
}

function readBool(fnc) {
  ansCallback = fnc;
  document.getElementById("yesNo").style.display = "block";
  document.getElementById("text").style.display = "none";
}

function readText(fnc) {
  ansCallback = fnc;
  document.getElementById("yesNo").style.display = "none";
  document.getElementById("text").style.display = "block";
}

function Yes() {
  if (ansCallback === null) return;
  ansCallback(true);
}

function No() {
  if (ansCallback === null) return;
  ansCallback(false);
}

function Answer() {
  if (ansCallback === null) return;
  let input = document.getElementById("answer");
  let value = input.value;
  input.value = "";
  ansCallback(value);
}

function print(msg) {
  document.getElementById("question").innerHTML = msg;
}

              
            
!
999px

Console