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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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.


                <!DOCTYPE html>
	<title>Guess the number</title>
	<link rel="stylesheet" href="" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <link rel="stylesheet" href="" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
  <script src=""></script>
  <script src=""></script>
  <script src=""></script>
	<link rel="stylesheet" type="text/css" href="index.scss">
	<div id="wrapper">
		<div class="description">
    <h1>Guess the number</h1>
		<p>We have selected a random number between 1 and 100. See if you can guess it in 10 turns or fewer. We'll tell you if your guess was too high or too low.</p>
	<div class="form">
		<label class="sr-only" for="userGuess">Enter your guess</label>
    <div class="row">
		<input class="col-xs-11 guessField" type="text" id="userGuess" placeholder="Enter your guess"/>
		<button class="col-xs-1 guessSubmit" type="submit"> Submit </button>
    <div class="resultParas">
      <p class="guesses"></p>
      <p class="lastResult"></p>
      <p class="lowOrHi"></p>
		<ul class="nav justify-content-end">
			<li class="nav-item"><a href="#" class="nav-link"><i class="fab fa-facebook"></i></a></li>
			<li class="nav-item"><a href="#" class="nav-link"><i class="fab fa-tumblr-square"></i></a></li>
      <li class="nav-item"><a href="#" class="nav-link"><i class="fab fa-twitter-square"></i></a></li>
      <li class="nav-item"><a href="#" class="nav-link"><i class="fab fa-weixin"></i></a></li>




                @import url('');

#wrapper {
	max-width: 600px; 
  padding: 30px;
  margin: auto;
  color: hsl(240, 60%, 90%);
	background-color: hsl(0, 0%, 10%);
  opacity: 0.6;
main h1 {
  text-align: center;
  padding: 20px;
  margin: 5px;
  word-spacing: 5px;
  letter-spacing: 2px;
  font-family: Modak, Serif;
main p {
  color: hsl(240, 59%, 90%);
  padding-bottom: 10px;
  max-length: 75ch;
  line-height: 1.8;
  letter-spacing: 1px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
  margin: auto;
  margin-bottom: 5px;
  padding: 10px;

  background-color: hsl(105, 25%, 20%);
  margin-right: 20px;

aside p {
  font-family: Modak;
  font-size: 1.5em;



                let randomNumber = Math.floor(Math.random() * 100) + 1;

const guesses = document.querySelector('.guesses');
const lastResult = document.querySelector('.lastResult');
const lowOrHi = document.querySelector('.lowOrHi');

const guessSubmit = document.querySelector('.guessSubmit');
const guessField = document.querySelector('.guessField');

let guessCount = 1;
let resetButton;
function checkGuess() {
  let userGuess = Number(guessField.value);
  if (guessCount === 1) {
    guesses.textContent = 'Previous guesses: ';
  guesses.textContent += userGuess + ' ';
  if (userGuess === randomNumber) {
    lastResult.textContent = 'Congratulations! You got it right!'; = 'green';
    lowOrHi.textContent = '';
  } else if (guessCount === 10) {
    lastResult.textContent = '!!!GAME OVER!!!';
  } else {
    lastResult.textContent = 'Wrong!'; = 'red';
    if(userGuess < randomNumber) {
      lowOrHi.textContent = 'Last guess was too low!';
    } else if(userGuess > randomNumber) {
      lowOrHi.textContent = 'Last guess was too high!';
  guessField.value = '';
guessSubmit.addEventListener('click', checkGuess);
function setGameOver() {
  guessField.disabled = true;
  guessSubmit.disabled = true;
  resetButton = document.createElement('button');
  resetButton.textContent = 'Start new game';
  resetButton.addEventListener('click', resetGame);
function resetGame() {
  guessCount = 1;

  const resetParas = document.querySelectorAll('.resultParas p');
  for (let i = 0 ; i < resetParas.length ; i++) {
    resetParas[i].textContent = '';


  guessField.disabled = false;
  guessSubmit.disabled = false;
  guessField.value = '';
  guessField.focus(); = 'white';

  randomNumber = Math.floor(Math.random() * 100) + 1;