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

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                // Adults example: Get the names of all adults in a list of people
const people = [
  { name: "Alice", age: 30 },
  { name: "Bob", age: 15 },
  { name: "Charlie", age: 35 },
  { name: "David", age: 21 },
  { name: "Eve", age: 12 }
];

//With Map and Filter
let adults = people.filter((p) => p.age >= 18).map((p) => p.name);
console.log("MapFilter:", adults);

//With For each
adults = [];
for (p of people) {
  if (p.age >= 18) adults.push(p.name);
}
console.log("ForEach", adults);

//With lambda and return keyword
adults = people.reduce((listOfAdults, p) => {
  if (p.age >= 18) listOfAdults.push(p.name);
  return listOfAdults;
}, []);
console.log("Reduce:", adults);

// #######################################################################
// Intro example

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

//With Regular Functions
let sum = numbers.reduce(function (total, n) {
  return total + n;
}, 0);
// console.log(sum);

//With lambda and return keyword
sum = numbers.reduce((total, n) => {
  return total + n;
}, 0);
// console.log(sum);

//With lambda and without return keyword
sum = numbers.reduce((total, n) => total + n, 0);
// console.log(sum);

              
            
!
999px

Console