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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm 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. We'll also process your JavaScript with Babel.

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

Code Indentation


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.

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="game-screen">
      <div id="console">
        <h1 style="display: none;">Guess <span id="the-word">A Random Word</span></h1>
        <div id="mystery_word"></div>
          <form id="answer_form">
            <label>Guess A Letter</label> <input type="text" value="" id="letter_guess" maxlength="1" />
            <button onClick="checkLetter(); return false;">Guess</button>
          <div id="result_message"></div>
          <div id="message_to_user"></div>
          <div id="misses-container">
            <h2>Misses: <span id="wrong_letter"></span></h2>
      </div><!-- console -->
</div><!-- game-screen -->

   font-family: courier, mono-space;

/*   position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%); */
  background: #333;
  bottom: 0;
  padding: 1em;
  font-size: 1.6em;

form input[type="text"]{
  width: 1em;
  margin-right: 1em;
  padding: .5em;
  text-align: center;

form button{
  display: inline-block;
  cursor: pointer;
  border-radius: .25em;
  border: none;
  padding: .5em;

  margin-bottom: 2em;
  color: #333;
  font-size: 1em;

  clear: left;
  content: '.';
  height: 0;
  width: 100%;
  display: block;
  visibility: hidden;

#mystery_word div{
  border: 1px solid #ccc;
  width: 1em;
  padding: .5em;
  float: left;
  text-align: center;
  margin-right: .5em;
  background: #fff;
  text-transform: lowercase;

#mystery_word div:first-child{
  text-transform: uppercase;

#misses-container h2{
  font-size: 1em;

              var answers = ["Face", "Place", "Habibi", "Panda" ,"Reptile",  "Flower", "Fishes"];
var mysteryWord = document.getElementById("mystery_word");
var message = document.getElementById("result_message");
var counterId = document.getElementById("wrong_counter");
var counterWrong = 0;
var wrongLetters = document.getElementById("wrong_letter");
var randomWord;
var answerIsSolved = false;
var messageToUser = document.getElementById("message_to_user");
var userChances = 3;

/////////End Screen Variables////////
var winMsg = "Congratulations You Won";
var loseMsg = "You Lose. The Word Was";
var endScreen = document.getElementById('end_screen');
var endMsg = document.getElementById('end_message');
var endImg = document.getElementById('end_message');


var genNumb = function(x){
  var randNumb = Math.floor(Math.random() * x);
  return randNumb;

var getWord = function(){
  randomWord = answers[genNumb( (answers.length) )];
  document.getElementById('the-word').innerHTML = randomWord;

var checkWin = function(){
  var mystryWordDivs = mysteryWord.getElementsByTagName('div');
  var winCounter = 0;
  for(let i=0; i<mystryWordDivs.length; i++){
  if(winCounter == mystryWordDivs.length){

var createBoxes = function(){
  for (let i = 0; i < randomWord.length; i++) {
    let answerBox = document.createElement("div");
	  answerBox.innerHTML = "?";

var clearAnswer = function(){
  document.getElementById("letter_guess").value ="";

var checkLetter = function(){
  messageToUser.innerHTML = "";
  var letterGuess = document.getElementById("letter_guess").value;
	let ansIsWrong = true;
  if( letterGuess == ""){
    messageToUser.innerHTML = "Please Enter A Letter";
  } else {
    for (let n = 0; n < randomWord.length; n++) {
  	  if( letterGuess.toLowerCase() == randomWord[n].toLowerCase() ){
  	    document.getElementById("letter_"+n).innerHTML = letterGuess;
  		  ansIsWrong = false;
    if(ansIsWrong == true){
  	  counterId.innerHTML = counterWrong;
      wrongLetters.innerHTML = wrongLetters.innerHTML+" "+letterGuess;
  	  ansIsWrong = false;
        if(counterWrong >= userChances){
          alert("Sorry. You Dead!\r The Word was "+ randomWord);

var youWin = function(){
  alert("You Win");

var youLoose = function(){
  endMsg.innerHTML = loseMsg;
  endImg.innerHTML = "Losing Icon goes here!";
  endScreen.style = "display: block;";

var startGame = function(){

window.addEventListener('load', startGame());
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.