Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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

              
                <article>
  <h2>JavaScript String Split</h2>
  <section>
    <aside id="left">
      <p>Syntax</p>
      <ul id="syntax">

      </ul>
    </aside>
    <aside id="right">
      <p>String Split Result From Console</p>
      <ul id="result">

      </ul>
    </aside>
  </section>
</article>
              
            
!

CSS

              
                * {
  text-align: center;
  font-size: 1.15rem;
}
section {
  border: solid 2px black;
  border-radius: 7px;
  margin: auto;
  background-color: #2d3e50;
}
article {
  width: 100%;
  text-align: center;
}
aside {
  margin: 2px;
}
p {
  border: solid 2px black;
  border-radius: 7px;
  background-color: #00bda5;
  margin: 5px;
  padding: 5px;
  color: #2d3e50;
}
#left {
  display: inline-grid;
  width: 25%;
}
#right {
  display: inline-grid;
  width: 65%;
}
ul {
  list-style: none;
  display: block;
  padding: 0px;
  margin: 0px;
}
li {
  border: solid 2px black;
  border-radius: 7px;
  text-align: left;
  color: white;
  margin: 5px;
  padding: 10px;
  background-color: #ff5c35;
}
#left li {
  text-align: center;
}

              
            
!

JS

              
                let intro = "Hello! I'm The Doctor.";

/*Returns
// [object Array] (1)
["Hello! I'm The Doctor."]
*/
let noParams = intro.split();

/*
// [object Array] (2)
["Hello"," I'm The Doctor."]
*/
let atSpecChar = intro.split("!");

/*
[object Array] (22)
["H","e","l","l","o","!"," ","I","'","m"," ","T","h","e"," ","D","o","c","t","o","r","."]
*/
let atEachChar = intro.split("");

/*
[object Array] (5)
["H","e","l","l","o"]
*/
let eachCharMaxFive = intro.split("", 5);

let splitExArray = [noParams, atSpecChar, atEachChar, eachCharMaxFive];
let splitExSyntax = [
  `intro.split()`,
  `intro.split("!")`,
  `intro.split("")`,
  `intro.split("", 5)`
];
for (i = 0; i < splitExArray.length; i++) {
  let exSyntax = document.createElement("LI");
  document.getElementById("syntax").appendChild(exSyntax);
  exSyntax.setAttribute("id", `playerNum${i + 1}`);

  //Create player number text node, then append text node
  let playerNum = document.createTextNode(`${splitExSyntax[i]} `);
  exSyntax.appendChild(playerNum);

  let splitExample = document.createElement("LI");
  document.getElementById("result").appendChild(splitExample);
  splitExample.setAttribute("id", `splitExample${i}`);
  let arrayItems = [];
  for (id = 0; id < splitExArray[i].length; id++) {
    arrayItems.push(`"${splitExArray[i][id]}"`);
  }
  let splitResult = document.createTextNode(`[${arrayItems}]`);
  document.getElementById("result").appendChild(splitExample);
  splitExample.appendChild(splitResult);
  splitExample.setAttribute("id", `noParams`);
}

              
            
!
999px

Console