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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <h2>All Restaurants</h2>
<ul id='restaurants'></ul>

<h2>Burger Joints</h2>
<ul id='burgerJoints'></ul>

<h2>Pizza Joints</h2>
<ul id='pizzaJoints'></ul>

<h2>Tex-Mex Joints</h2>
<ul id='texMexJoints'></ul>
<h2>Cheap Joints</h2>
<ul id='cheapJoints'></ul>
<h2>Moderately Priced Joints</h2>
<ul id='moderateJoints'></ul>
<h2>Expensive Joints</h2>
<ul id='expensiveJoints'></ul>
              , *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;

body {
  margin: 0;
  padding: 1rem;
  font-size: 16px;
  line-height: 1.4;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
              // restaurants array imported from https://codepen.io/AdamGiese/pen/xJPPBV

const isKeyEqualToValue = key => value => object => object[key] === value;
const isPrice   = isKeyEqualToValue('price');
const isCuisine = isKeyEqualToValue('cuisine');

const isBurger    = isCuisine('Burger');
const isPizza     = isCuisine('Pizza');
const isTexMex    = isCuisine('Tex-Mex');

const isCheap     = isPrice('Cheap');
const isModerate  = isPrice('Moderate');
const isExpensive = isPrice('Expensive');

renderList(restaurants, 'restaurants'); 
renderList(restaurants.filter(isBurger), 'burgerJoints');
renderList(restaurants.filter(isPizza), 'pizzaJoints');
renderList(restaurants.filter(isTexMex), 'texMexJoints');

renderList(restaurants.filter(isCheap), 'cheapJoints');
renderList(restaurants.filter(isModerate), 'moderateJoints');
renderList(restaurants.filter(isExpensive), 'expensiveJoints');

// simple rendering function
function renderList (restaurantList, listId) {
  const list = document.getElementById(listId);
  const listItems = restaurantList.map(({name}) => {
    const item = document.createElement('li');
    item.innerText = name;
    return item;
  listItems.forEach(listItem => {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.