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.


                <div id="container"></div>


                span {
	display: inline-block;
	text-align: center;

#container>div {
	padding-top: 5px


* A Pascal Triangle in ES6.
* (
* Use: scroll down to the instantiation and add the desired
* number of lines
* Author: Jean-Pierre Sierens
class PascalTriangle {
  	constructor (levels) {
		// the number of levels the triangle will have
    	this.levels = levels;
	create () {
  	createLevel (level, prevNums) {
		//get the numbers for this level
		let numbers = this.calculateLevelNumbers(level, prevNums);
		//log the level
		this.logLevel(numbers, level);
		//go to the next level (if its not the last)
		if (level !== this.levels) return this.createLevel(level+1, numbers);
	calculateLevelNumbers (level, prevNums) {
		let numbers = [];
		if (level === 1) {
			return numbers;
		// iterate over each number in the level
		for (let i = 0; i < level; i++) {
			// if it's the first or last number it's always 1
			if (i === 0 || i === level - 1) {
			} else {
				// the number becomes the sum of the two above him
				numbers.push( prevNums[i-1] + prevNums[i] );	
		return numbers;
	logLevel (numbers, level) {
		//create empty div where the numbers will go (holder)
		let $numbers = $("<div></div>");
		//padding for each holder, so that you get a nice triangle
		let padding = (this.levels - level) * this.levels*2;
		$numbers.css('padding-left', padding);
		//for each number append a span with a width, then append it to the numbers holder
		//note: arrow function for mantaining lexical scope (fuck yeah)
		numbers.forEach( (number, index) => {
				"<span style='width: "+this.levels*4+"px'>"+number+"</span>"


// Instantiation
// change the number to add more or less levels to the triangle
let pt = new PascalTriangle(10);