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 includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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 >
    <meta charset="UTF-8">
    <title>Guessing Game - JS 1</title>
    <link rel='stylesheet prefetch' href=''>

        <link rel="stylesheet" href="css/style.css">


<body class="background">
  <div class="container-fluid">
    <div class="center">
      <!-- Game title -->
      <h1>Guessing Game</h1>
      <p id='helper-text'>Enter a guess from 1-100. Guess right to win a prize!</p>

      <form id="guessing-form">
          <!-- Number input box -->
          <input class='hide-me' id="number-input" type="text" placeholder="Enter a guess" autocomplete="off">
          <!-- Hint button -->
          <button id="hint-btn" class="btn btn-default hide-me" type="button">Give a hint</button>
          <!-- Submit button -->
          <button id='submit-btn' class="btn btn-lg btn-primary hide-me" type="button">Submit</button>
          <!-- Start Over button -->
          <button id='startover-btn' class="btn btn-default" type="button">Start Over!</button>
      <div id='prev-guesses' class='hide-me'></div>
      <!-- Remaining guesses -->
      <div class='hide-me'><p>Remaining Guesses:</p><h4 id="guesses-remaining">5</h4></div>
      <div id="prize-image"></div>

    <script src=''></script>

        <script src="js/index.js"></script>



                .center {
  margin: 0 auto;
  text-align: center;

#number-input {
  width: 350px;
  height: 60px;
  text-align: center;
  margin: 1.5%;

p, h1, h4, .btn {
  margin: 10px;

h1 {
  margin: 50px;

.background {
  background-color: ;

p {
    font-size: 16px;
  padding-top: 10px;

img {
  width: 400px;
  height: 350px;
  margin-top: 50px;



                var num = Math.floor(Math.random() * 101);
var guesses=5;
var prevGuess;
document.getElementById("submit-btn").onclick = function() {
    var playerNum =           parseInt(document.getElementById("number-input").value);
    if (playerNum == num) {
      document.getElementById("number-input").disabled= true;
        document.getElementById("submit-btn").disabled= true;
        document.getElementById("hint-btn").disabled= true;
    else {
      document.getElementById("number-input").placeholder = "Wrong! Try again."
      if (guesses==0) {
        document.getElementById("number-input").placeholder="Game Over. The number was "+num;
        document.getElementById("number-input").disabled= true;
        document.getElementById("submit-btn").disabled= true;
        document.getElementById("hint-btn").disabled= true;

document.getElementById("startover-btn").onclick= function() {
  num = Math.floor(Math.random() * 101);
  document.getElementById("number-input").disabled= false;
    document.getElementById("submit-btn").disabled= false;
    document.getElementById("hint-btn").disabled= false;
  document.getElementById("number-input").placeholder="Enter a guess"

document.getElementById("hint-btn").onclick= function() {
  if (num < prevGuess) {
    document.getElementById("number-input").placeholder="The number is less than the number you chose";
  else {
    document.getElementById("number-input").placeholder="The number is greater than the number you chose";