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

              
                <!-- <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> -->

<!-- ******************** Navigation section ******************** -->
<div id="wrapper">
<nav id="navbar">
  <header>
    <h1>Javascript<br>documentation</h1>
  </header>
  <ul>
    <a href="#introduction" class="nav-link"><li>Introduction</li></a>
    <a href="#grammar_and_types" class="nav-link"><li>Grammar and types</li></a>
    <a href="#declarations" class="nav-link"><li>Declarations</li></a>
    <a href="#data_structures" class="nav-link"><li>Data structures</li></a>
    <a href="#conditional_statements" class="nav-link"><li>Conditional statements</li></a>
  </ul>
</nav>

<!-- ******************** Main section ******************** -->

<!-- ********** Main section - Introduction ********** -->

<main id="main-doc">
  <section class="main-section" id="introduction">
    <header>Introduction</header>
    <article>
      <p>JavaScript is a cross-platform, object-oriented scripting language used to make webpages interactive (e.x. having complex animations, clickable buttons, popup menus, etc.).  There are also more advanced server side versions of javascript such as Node.Js which allow you to add more functionality to a website than simply downloading files (such as realtime collaboration between multiple computers). 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 <span class="highlight">Array</span>, <span class="highlight">Date</span>, and <span class="highlight">Math</span>, 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:</p>
      <ul>
        <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>
      </ul>
      <p>This means that in the browser, JavaScript can change the way the webpage (DOM) looks. And, likewise, Node.js JavaScript on the server can respond to custom requests from code written in the browser.</p>
    </article>
  </section>
  
  <!-- ********** Main section - Grammar and types ********** -->
  
  <section class="main-section" id="grammar_and_types">
    <header>Grammar and types</header>
    <article>
      <p>JavaScript borrows most of its syntax from Java, but is also influenced by Awk, Perl and Python.</p>
      <p>JavaScript is <strong>case-sensitive</strong> and uses the <strong>Unicode</strong> character set. For example, the word Früh (which means "early" in German) could be used as a variable name.</p>
      <div class="codeStyle">
        <code>let Früh = "foobar";</code>
      </div>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
    </article>
  </section>
  
  <!-- ********** Main section - Declarations ********** -->
  
  <section class="main-section" id="declarations">
    <header>Declarations</header>
    <article>
      <p><span class="highlight">var</span> Declares a variable, optionally initializing it to a value.</p>
      <p><span class="highlight">let</span> Declares a block-scoped, local variable, optionally initializing it to a value.</p>
      <p><span class="highlight">const</span> Declares a block-scoped, read-only named constant.</p>
      <h4>Variables</h4>  
      <p>You use variables as symbolic names for values in your application. The names of variables, called identifiers, conform to certain rules.</p>
      <p>A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).</p>
      <p>Some examples of legal names are <span class="highlight">Number_hits</span>, <span class="highlight">temp99</span>, <span class="highlight">$credit</span>, and <span class="highlight">_name</span>.</p>
      <h4>Declaring variables</h4>
      <p>A variable declared using the <span class="highlight">var</span> or <span class="highlight">let</span> statement with no assigned value specified has the value of <span class="highlight">undefined</span>.</p>
      <p>An attempt to access an undeclared variable results in a <span class="highlight">ReferenceError</span> exception being thrown:</p>
      <div class="codeStyle">
        <code>
          var a;<br>
          console.log('The value of a is ' + a); // The value of a is undefined<br>
          console.log('The value of b is ' + b); // The value of b is undefined<br>
          var b;<br>
          console.log('The value of c is ' + c); // Uncaught ReferenceError: c is not defined<br>
          let x;<br>
          console.log('The value of x is ' + x); // The value of x is undefined<br>
          console.log('The value of y is ' + y); // Uncaught ReferenceError: y is not defined<br>
          let y; 
        </code>
      </div>
      <p>You can use <span class="highlight">undefined</span> to determine whether a variable has a value. In the following code, the variable <span class="highlight">input</span> is not assigned a value, and the <span class="highlight">if</span> statement evaluates to <span class="highlight">true</span>.</p>
      <div class="codeStyle">
        <code>
          var input;<br>
          if (input === undefined) {<br>
          doThis();<br>
          } else {<br>
          doThat();<br>
          }
        </code>
      </div>
      <p>The <span class="highlight">undefined</span> value behaves as <span class="highlight">false</span> when used in a boolean context. For example, the following code executes the function <span class="highlight">myFunction</span> because the <span class="highlight">myArray</span> element is undefined:</p>
      <div class="codeStyle">
        <code>
          var myArray = [];<br>
          if (!myArray[0]) myFunction();
        </code>
      </div>
      <p>The <span class="highlight">undefined</span> value converts to <span class="highlight">NaN</span> when used in numeric context.</p>
       <div class="codeStyle">
        <code>
          var a;<br>
          a + 2;  // Evaluates to NaN
        </code>
      </div>
      <p>When you evaluate a <span class="highlight">null</span> variable, the null value behaves as 0 in numeric contexts and as false in boolean contexts. For example:</p>
      <div class="codeStyle">
        <code>
          var n = null;<br>
          console.log(n * 32); // Will log 0 to the console
        </code>
      </div>
    </article>
  </section>
  
  <!-- ********** Main section - Data structures ********** -->
  
  <section class="main-section" id="data_structures">
    <header>Data structures</header>
    <article>
      <h4>Data types</h4>
      <p>The latest ECMAScript standard defines seven data types:</p>
      <ul>
        <li>Six data types that are primitives:</li>
        <ul>
          <li>Boolean. <span class="highlight">true</span> and <span class="highlight">false</span>.</li>
          <li>null. A special keyword denoting a null value. Because JavaScript is case-sensitive, <span class="highlight">null</span> is not the same as <span class="highlight">Null</span>, <span class="highlight">NULL</span>, or any other variant.</li>
          <li>undefined. A top-level property whose value is not defined.</li>
          <li>Number. An integer or floating point number. For example: <span class="highlight">42</span> or <span class="highlight">3.14159</span>.</li>
          <li>String. A sequence of characters that represent a text value. For example:  "Howdy"</li>
          <li>Symbol (new in ECMAScript 2015). A data type whose instances are unique and immutable.</li>
        </ul>
        <li>and Object</li>
      </ul>
      <p>Llthough these data types are relatively few, they enable you to perform useful functions with your applications. <span class="highlight">Objects</span> and <span class="highlight">functions</span> are the other fundamental elements in the language. You can think of objects as named containers for values, and functions as procedures that your application can perform.</p>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>
      <h4>Data type conversion</h4>
      <p>JavaScript is a dynamically typed language. That means you don't have to specify the data type of a variable when you declare it, and data types are converted automatically as needed during script execution. So, for example, you could define a variable as follows:</p>
       <div class="codeStyle">
        <code>
          var answer = 42;
        </code>
      </div>
      <p>And later, you could assign the same variable a string value, for example:</p>
       <div class="codeStyle">
        <code>
          answer = 'Thanks for all the fish...';
        </code>
      </div>
      <p>Because JavaScript is dynamically typed, this assignment does not cause an error message.</p>
      <p>In expressions involving numeric and string values with the + operator, JavaScript converts numeric values to strings. For example, consider the following statements:</p>
      <div class="codeStyle">
        <code>
          x = 'The answer is ' + 42 // "The answer is 42"<br>
          y = 42 + ' is the answer' // "42 is the answer"
        </code>
      </div>
      <p>In statements involving other operators, JavaScript does not convert numeric values to strings. For example:</p>
      <div class="codeStyle">
        <code>
          '37' - 7 // 30<br>
          '37' + 7 // "377"
        </code>
      </div>
    </article>
  </section>
  
  <!-- ********** Main section - Conditional statements ********** -->
  
  <section class="main-section" id="conditional_statements">
    <header>Conditional statements</header>
    <article>
      <p>A conditional statement is a set of commands that executes if a specified condition is true. JavaScript supports two conditional statements: <span class="highlight">if...else</span> and <span class="highlight">switch</span>.</p>
      <h4>if...else statements</h4>
      <p>Use the <span class="highlight">if</span> statement to execute a statement if a logical condition is true. Use the optional <span class="highlight">else</span> clause to execute a statement if the condition is false. An <span class="highlight">if</span> statement looks as follows:</p>
      <div class="codeStyle">
        <code>
          if (condition) {<br>
          statement_1;<br>
          } else {<br>
          statement_2;<br>
          }
        </code>
      </div>
      <p>Here the <span class="highlight">condition</span> can be any expression that evaluates to true or false. If <span class="highlight">condition</span> evaluates to true, <span class="highlight">statement_1</span> is executed; otherwise, <span class="highlight">statement_2</span> is executed. <span class="highlight">statement_1</span> and <span class="highlight">statement_2</span> can be any statement, including further nested <span class="highlight">if</span> statements.</p>
      <p>You may also compound the statements using <span class="highlight">else if</span> to have multiple conditions tested in sequence, as follows:</p>
      <div class="codeStyle">
        <code>
          if (condition_1) {<br>
          statement_1;<br>
          } else if (condition_2) {<br>
          statement_2;<br>
          } else if (condition_n) {<br>
          statement_n;<br>
          } else {<br>
          statement_last;<br>
          } 
        </code>
      </div>
      <p>In the case of multiple conditions only the first logical condition which evaluates to true will be executed. To execute multiple statements, group them within a block statement (<span class="highlight">{ ... }</span>) . In general, it's good practice to always use block statements, especially when nesting <span class="highlight">if</span> statements:</p>
      <div class="codeStyle">
        <code>
          if (condition) {<br>
          statement_1_runs_if_condition_is_true;<br>
          statement_2_runs_if_condition_is_true;<br>
          } else {<br>
          statement_3_runs_if_condition_is_false;<br>
          statement_4_runs_if_condition_is_false;<br>
          }
        </code>
      </div>
    </article>
  </section>
  <p>Content for the documentation was taken from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide">MDN Web Docs</a>.
</main>

<!-- ******************** Footer section ******************** -->
  
</wrapper>
              
            
!

CSS

              
                * {
  font-family: "Arial", sans-serif;
  padding: 0;
  margin: 0;
}

#wrapper {
  display: flex;
  flex-direction: column;
}

h1 {
  padding-top: 0.5em;
  padding-bottom: 0.5em;  
  color: DarkTurquoise;
}

header {
  padding: 0.7em;
  font-weight: bold;
  font-size: 1.3em;
  color: DarkTurquoise;
}

h4 {
  padding-top: 0.5em;
  padding-bottom: 0.5em;  
  color: DarkTurquoise;
  padding: 0.7em;
  font-size: 1.3em;
}

a {
  text-decoration: none;
  color: black;
}

p {
  line-height: 1.5;
  padding: 0.7em;
}

/* ---------- Navigation section ---------- */

nav ul {
  background-color: PaleTurquoise;  
}

nav ul:last-child {
  border-bottom: 1px solid black;
}

nav li {
  border-top: 1px solid black;
  list-style-type: none;
  padding: 0.7em;
}

/* ---------- Main section ---------- */

section {
  max-width: 750px;
}

section header {
    font-size: 1.6em;
}

article ul {
  margin-left: 1.8em;
}

article li {
  list-style-type: circle;
  line-height: 1.5;
  padding: 0.4em;
  
}

.highlight {
  background-color: LightCyan;
  font-family: "Consolas", "Monaco", sans-serif;
  padding-left: 0.2em;
  padding-right: 0.2em;
  border-radius: 4px;
}

.codeStyle {
  background-color: LightCyan;
  margin: 0.7em;
  padding: 0.2em;
  border-radius: 4px;
}

code {
  font-family: "Consolas", "Monaco", sans-serif;
  line-height: 1.5;
}

p a {
  text-decoration: underline;
  color: DarkTurquoise;
}

@media only screen and (min-width: 700px) {
  #wrapper {
  display: flex;
  flex-direction: row;
}
  
  nav {
   border-right: 1px solid black;
   position: fixed;
   background: white;
   height: 100%;
   width: 20em;
  }
  
  main {
    padding-left: 335px;
  }
}
              
            
!

JS

              
                // !! IMPORTANT README:

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

/***********
INSTRUCTIONS:
  - Select the project you would 
    like to complete from the dropdown 
    menu.
  - Click the "RUN TESTS" button to
    run the tests against the blank 
    pen.
  - 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. 

              
            
!
999px

Console