Pen Settings



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


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.


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.




    box-sizing: border-box;
body {
  font-family: sans-serif;
  margin: 10px 30px;
.wrapper {
    max-width: 960px;
    margin: 10px auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
.product {
    flex: 0 0 19%; 
    border: 1px dotted #aaa;
    padding: 10px;
    margin-bottom: 10px;
.product h3 {
    margin: 10px 0;
img {max-width: 100%;}
.price {
    margin: 10px 0;
del {color: #ccc;}
ins {
    color: #f00;
    text-decoration: none;
.not-available {
    opacity: 0.5;
.stock {
    color: green;
.not-available .stock {
    color: red;
@media (max-width: 800px){
  .product {
    flex: 0 0 49%; 


                const URL = '//';
const books = [{
    title: "Коллекционер",
    author: "Фаулз Дж.",
    cover: 'books/b0.jpg',
    price: 148,
    sale: null,
    inStock: true
    title: "Я слежу за тобой",
    author: "Дрисколл Т.",
    cover: 'books/b1.jpg',
    price: 213,
    sale: 189,
    inStock: true
} ,{
    title: "Рассказы о Шерлоке Холмсе",
    author: "Дойл А.",
    cover: 'books/b2.jpg',
    price: 104,
    sale: 83,
    inStock: true
}, {
    title: "Снеговик",
    author: "Ю Несбё",
    cover: 'books/b3.jpg',
    price: 75,
    sale: null,
    inStock: false
} , {
    title: "Головоломка",
    author: "Тилье Ф.",
    cover: 'books/b4.jpg',
    price: 50,
    sale: null,
    inStock: false
} , {
    title: "Время предательства",
    author: "Пенни Л.",
    cover: 'books/b5.jpg',
    price: 61,
    sale: null,
    inStock: false
} , {
    title: "Планета Вода.",
    author: "Акунин Б.",
    cover: 'books/b6.jpg',
    price: 1059,
    sale: null,
    inStock: true
}, {
    title: "Женщина в окне",
    author: "А.Дж. Финн",
    cover: 'books/b7.jpg',
    price: 175,
    sale: 149,
    inStock: true
} , {
    title: "Игра на выживание",
    author: "Владимирская А.",
    cover: 'books/b8.jpg',
    price: 397,
    sale: 140,
    inStock: true
} , {
    title: "Точка обмана",
    author: "Браун Д.",
    cover: 'books/b9.jpg',
    price: 183,
    sale: null,
    inStock: false
} ];

function bookFilter(type){
    return books.filter(function (book) { 
        return book[type];
    }).map(function (book) {
        return" "+book.title;
function printBookList(arr){   
    const list = arr.reduce(function (html, elem) {
       // console.log(html, elem);
    html += '<li>' + elem + '</li>';
    return html;
  }, '<ol>') + '</ol>';
  return list;
function printBookListMin(arr){   
    return arr.reduce((html, elem) => html += '<li>' + elem + '</li>', '<ol>') + '</ol>';
//document.write( printBookList(books) );
function printBookListAll(arr, currency="грн."){
    const block = arr.reduce(function (html, elem) {
        let sale = ? `<div class="price"><del>${elem.price} ${currency}</del> <ins class="sale">${} ${currency}</ins></div>` : `<div class="price">${elem.price} ${currency}</div>`;
        let inStockClass = elem.inStock ? '': " not-available";
    html += `
    <div class="product${inStockClass}">
        <div class="cover"><img src="${URL}${elem.cover}" alt="${elem.title}"></div>  
        <div class="author">${}</div> 
        <div class="stock">${elem.inStock ? "Есть на складе" : "Нет на складе"}</div>
    return html;
  }, '<div class="wrapper">') + '</div>';
  return block;
document.write( printBookListAll(books) );
const saleBooks = bookFilter('sale');
document.write('<h2>Книги по распродаже</h2>');
document.write( printBookList(saleBooks) );
const inStockBooks = bookFilter('inStock')
document.write('<h2>Книги в наличии</h2>');
document.write( printBookListMin(inStockBooks) );