cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

              <nav id="navbar">
      <h1>JS Documentation</h1>
      <a class="nav-link" href="#Introduction" title="Introduction"><li>Introduction</li></a>
      <a class="nav-link" href="#What_you_should_already_know" title="What you should already know"><li>What you should already know</li></a>
      <a class="nav-link" href="#JavaScript_and_Java" title="JavaScript and Java"><li>JavaScript and Java</li></a>
      <a class="nav-link" href="#Hello_World" title="Hello World"><li>Hello World</li></a>
      <a class="nav-link" href="#Variables" title="Variables"><li>Variables</li></a>
      <a class="nav-link" href="#Variable_Scope"  title="Variable Scope"><li>Variable Scope</li></a> 
<main id="main-doc">
  <section id="Introduction" class="main-section">
    <p>JavaScript is a cross-platform, object-oriented scripting language. It is a small and lightweight language. Inside a host environment (for example, a web browser), JavaScript can be connected to the objects of its environment to provide programmatic control over them.</p>

<p>JavaScript contains a standard library of objects, such as Array, Date, and Math, and a core set of language elements such as operators, control structures, and statements. Core JavaScript can be extended for a variety of purposes by supplementing it with additional objects; for example:
    <li>Client-side JavaScript extends the core language by supplying objects to control a browser and its Document Object Model (DOM). For example, client-side extensions allow an application to place elements on an HTML form and respond to user events such as mouse clicks, form input, and page navigation.</li>
<li>Server-side JavaScript extends the core language by supplying objects relevant to running JavaScript on a server. For example, server-side extensions allow an application to communicate with a database, provide continuity of information from one invocation to another of the application, or perform file manipulations on a server.</li>
  <section id="What_you_should_already_know" class="main-section">
    <header>What you should already know</header>
    <p>This guide assumes you have the following basic background:
        <li>A general understanding of the Internet and the World Wide Web (WWW).</li>
        <li>Good working knowledge of HyperText Markup Language (HTML).</li>
        <li>Some programming experience. If you are new to programming, try one of the tutorials linked on the main page about JavaScript.</li>
  <section id="JavaScript_and_Java" class="main-section">
    <header>JavaScript and Java</header>
    <p>JavaScript and Java are similar in some ways but fundamentally different in some others. The JavaScript language resembles Java but does not have Java's static typing and strong type checking. JavaScript follows most Java expression syntax, naming conventions and basic control-flow constructs which was the reason why it was renamed from LiveScript to JavaScript.</p>
    <p>In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a runtime system based on a small number of data types representing numeric, Boolean, and string values. JavaScript has a prototype-based object model instead of the more common class-based object model. The prototype-based model provides dynamic inheritance; that is, what is inherited can vary for individual objects. JavaScript also supports functions without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.</p>
    <p>JavaScript is a very free-form language compared to Java. You do not have to declare all variables, classes, and methods. You do not have to be concerned with whether methods are public, private, or protected, and you do not have to implement interfaces. Variables, parameters, and function return types are not explicitly typed.</p>
  <section id="Hello_World" class="main-section">
    <header>Hello World</header> 
    <p>To get started with writing JavaScript, open the Scratchpad and write your first "Hello world" JavaScript code:</p>
      <p><pre><code>function greetMe(yourName) {
  alert("Hello " + yourName);
  <p>Select the code in the pad and hit Ctrl+R to watch it unfold in your browser! </p>
  <section id="Variables" class="main-section">
    <p>You can declare a variable in three ways:</p>
    <p>With the keyword var. For example,
    <pre><code>var x = 42.</code></pre>
    This syntax can be used to declare both local and global variables.</p>
<p>By simply assigning it a value. For example,
<pre><code>x = 42.</code></pre>
This always declares a global variable. It generates a strict JavaScript warning. You shouldn't use this variant.</p>
<p>With the keyword let. For example,
<pre><code>let y = 13.</code></pre>
This syntax can be used to declare a block scope local variable. See Variable scope below.</p>
  <section id="Variable_Scope" class="main-section">
    <header>Variable Scope</header>
    <p>When you declare a variable outside of any function, it is called a global variable, because it is available to any other code in the current document. When you declare a variable within a function, it is called a local variable, because it is available only within that function.</p>
    <>JavaScript before ECMAScript 2015 does not have block statement scope; rather, a variable declared within a block is local to the function (or global scope) that the block resides within. For example the following code will log 5, because the scope of x is the function (or global context) within which x is declared, not the block, which in this case is an if statement.
    <pre><code>if (true) {
  var x = 5;
console.log(x);  // 5

<p>This behavior changes, when using the let declaration introduced in ECMAScript 2015.
  <pre><code>if (true) {
  let y = 5;
// ReferenceError: y is not defined
  margin: 0px;
  padding: 15px 0 0;
 #navbar {
  border-right: 2px solid #333;
  height: 100%;
  left: 0;
  position: fixed;
  top: 0;
#main-doc {
  margin-left: 250px;
  padding: 0 30px;
#navbar ul{ 
  list-style-type: none;
  margin: 0px;
  overflow: auto;
  padding: 0px;
#navbar li {
  border-top: 1px solid #333;
  color: #333;
  margin: 0px;
  padding: 15px;
#navbar a:hover,
#navbar a,
#navbar a:active,
#navbar a:visited {
  color: #333;
  text-decoration: none;

h1 {
  margin: 0 auto;
  padding: 20px;
  text-align: center;
#main-doc header {
  font-size: 1.5em;
#main-doc li,
pre {
  line-height: 2em;
  margin-left: 1em;
pre {
  background: #f7f7f7;
  border-radius: 5px;
  display: block;
  padding: 10px;

/* ----------- Non-Retina Screens ----------- */
@media screen 
  and (max-device-width: 1200px) 
  and (-webkit-min-device-pixel-ratio: 1) { 
    #navbar {
      position: relative;
    #navbar li {
      display: inline;

              var temp = document.getElementById('navbar').offsetWidth;
document.getElementById("main-doc").style.marginLeft = temp + "px";

// You may add additional external JS and CSS as needed to complete the project, however the current external resource MUST remain in place for the tests to work. BABEL must also be left in place. 

  - Select the project you would 
    like to complete from the dropdown 
  - Click the "RUN TESTS" button to
    run the tests against the blank 
  - Click the "TESTS" button to see 
    the individual test cases. 
    (should all be failing at first)
  - Start coding! As you fulfill each
    test case, you will see them go   
    from red to green.
  - As you start to build out your 
    project, when tests are failing, 
    you should get helpful errors 
    along the way!

// PLEASE NOTE: Adding global style rules using the * selector, or by adding rules to body {..} or html {..}, or to all elements within body or html, i.e. h1 {..}, has the potential to pollute the test suite's CSS. Try adding: * { color: red }, for a quick example!

// Once you have read the above messages, you can delete all comments. 

Loading ..................