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.


                <title>Simple Page</title>
          <h1 id="mainHeading"> Interesting Headline</h1>
                <p>This is a VERY  simple html page</p>
                <script type="text/javascript" src=“script.js”></script> 

                This source line wasn't working on my desktop, and it doesn't seem to needed here in I fear something may not be working here. -->




var name = prompt("What is your name?")
alert("Hello, " + name);

var a;
a = 5
a = 1000000
a = 123.456
a = -500

var phrase = "This is a simple phrase.";

var name = prompt("What is \nyour name?");
var message = "Hello,";
alert(message + name);

//conditionals, chapter 4

var a = 5;
var b = 10;

if (a < b){
    alert("Yes a is less than b");

if (a == b){
  alert("Yes, a is equal to b");

//else statements

var balance = 5000

if (balance >= 0) {
  alert("Yes, you have money!");
  if (balance >= 10000) {
    alert("The balance is large!")
} else {
  alert("Looks like you're out of money!");

//strict equality, using ===

var a = 123;
var b = "123";

//equality check

if (a == b){
  alert("They equal!");
} else {
  alert("They are not equal!");
//shows equality. js is being flexible here
//if I make the above ===, different result
if (a === b){
  alert("They equal!");
} else {
  alert("They are not equal!");
//for the above, !== strictly not equal also works. 


var grade = "Premium";

switch ( grade ) {
        case "Regular":
                alert("It's $3.15");
                break; //add this break here to prevent fall through reading of the rest of the switch
        case "Premium":
                alert("It's $3.35");
        case "Diesel":
                alert("It's $3.47");
                alert("That's not a valid grade");

//time to take a look at functions

function myFunction(){
        var a = 5;
        var b = 10;
        var c = 20;
        var d = a + b + c;
        alert("The value of d is: " + d);


// parameterize functions

//parameterize a and b

function addTwoNumbers(a,b)        {
        var result = a + b;

//when calling, function expects values for the a and b buckets. 
//we can create variables within, or, we can give values when we call the function.


//check this out

function addTwoNumbers(a,b)        {
        var result = a + b;
        return result; // return produces the value and jumps you right out of block


//now, let's store multiple iterations of the function call

//...but, this works when you call the function multiple times, and you want to store multiple values

function addTwoNumbers(a,b)        {
        var result = a + b;
        return result;                                       

var x = addTwoNumbers(5,10);
var y = addTwoNumbers(10,20);
var z = addTwoNumbers(100,200);

//writing an iterative loop

var amount = 0;

//create the index
var i = 1;

//check condition
while ( i < 10 ) {
        amount = amount + 100;
        //iterate index

alert("The value is " + amount);

//regular expressions
//Next we need to test our regex object.

//var myRE = new RegExp("hello");
//var myString = "Does this sentence have the word hello in it?";

//if ( myRE.test(MyString) ) //

//right now we return a string, Yes, but regex has other methods to return more complex objects
//!!!!I can't seem to get the above to work. Wierd

var myArray = [10,20,"test","TRUE",99]

var i = 0;

while ( i < myArray.length ) {
alert("The value is:" + myArray[i]);

//another example of iterating through an array

var myArray = [500,500,500,500,500]

var total = 0

for ( var i = 0; i < myArray.length; i++ ) {
        //add the durrent element to the total
        total = total + myArray[i];

//after we're done with the loop
alert("The total is: " + total);