cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <p style="text-align:left;">If this demo has brought you even a modicum of joy, please consider <a href="https://www.paypal.me/RobertGravelle/1" target="_blank">donating $1 dollar</a> (secure PayPal link) for a coffee or purchasing one of my songs from <a href="https://ax.itunes.apple.com/WebObjects/MZSearch.woa/wa/search?term=rob%20gravelle" target="_blank">iTunes.com</a> or <a href="http://www.amazon.com/s/ref=ntt_srch_drd_B001ES9TTK?ie=UTF8&field-keywords=Rob%20Gravelle&index=digital-music&search-type=ss" target="_blank">Amazon.com</a> for only 0.99 cents each.</p>
<p style="text-align:left;">Rob uses and recommends <a href="http://www.mochahost.com/2425.html" target="_blank">MochaHost</a>, which provides Web Hosting for as low as $1.95 per month, as well as unlimited emails and disk space!</p>

<p>Pssst: Open the console to view the results.</p>
            
          
!
            
              var menuData = [
  '/wp-content/plugins/menu-plugin/images/menu-item.png',
  'French Butter Croissant',
  '1.20/1.20',
  'Our croissants have all the flavour and lightness of a classic French croissant.',
  'menu_type_vegetarian',
  'menu_allergen_gluten',
  'menu_allergen_milk',
  'menu_allergen_eggs',
  'menu_allergen_soya_beans',
  '/wp-content/plugins/menu-plugin/images/menu-item.png',
  'Pretzels',
  '1.25/1.50',
  'There are three different types of our Pretzel (plain, poppy seeds or sesame).',
  'menu_type_vegan',
  'menu_type_vegetarian',
  'menu_allergen_gluten',
  'menu_allergen_sesame',
  '/wp-content/plugins/menu-plugin/images/menu-item.png',
  'Free-Range Egg Mayo & Roasted Tomato Breakfast Baguette',
  '1.99/2.39',
  'Chunky egg mayonnaise and roasted tomatoes are a great breakfast combination.',
  'menu_type_vegetarian',
  'menu_allergen_gluten',
  'menu_allergen_eggs',
  'menu_allergen_celery',
  'menu_allergen_mustard',
  'menu_allergen_sesame',
  '/wp-content/plugins/menu-plugin/images/menu-item.png',
  'Five Berry Pot',
  '1.35/1.60',
  'A simple little pot; very berry compote topped with natural yoghurt.',
  'menu_type_vegetarian',
  'menu_allergen_milk',
];

Array.prototype.arraySplitReverse = function(pattern, removeMatchedElements){
  var arr = this, retval = [], i = arr.length; 
  
  while ( --i ) {
    if (typeof(arr[i]) === 'string' && pattern.test(arr[i])) {
      //remove all elements up till end of array
      var tmpArray = arr.splice(i);
      //remove first (matched) element from temp array
      if (removeMatchedElements === true) tmpArray.shift();
      //add the temp array to the start of the new array
      //as a 2nd dimension
      retval.unshift(tmpArray);
      //reset i
      i = arr.length;
    }
  }
  
  return retval.length > 0 ? retval : arr;
}

console.log( menuData.arraySplitReverse(/^(https?:\/)?\/\S+\.(?:jpg|png|gif)$/i) );

console.log( menuData.arraySplitReverse(/^(https?:\/)?\/\S+\.(?:jpg|png|gif)$/i, true) );


            
          
!
999px
🕑 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.
Loading ..................

Console