Skip to content

Instantly share code, notes, and snippets.

@ryanclark
Last active April 12, 2016 20:35
Show Gist options
  • Select an option

  • Save ryanclark/bf78004d5493d67c7759dd51802c844c to your computer and use it in GitHub Desktop.

Select an option

Save ryanclark/bf78004d5493d67c7759dd51802c844c to your computer and use it in GitHub Desktop.
Array.prototype.spice = (() => {
var spices = [
'Ajwain',
'Akudjura',
'Alexanders',
'Alkanet',
'Alligator Pepper',
'Allspice',
'Angelica',
'Anise',
'Anise Hyssop',
'Anisseed Myrtle',
'Annatto',
'Apple Mint',
'Artemisia',
'Asafoetida',
'Asarabacca',
'Avens',
'Avocado Leaf',
'Barberry',
'Basil',
'Bay Leaf',
'Bee Balm',
'Boldo',
'Borage',
'Blue Fenugreek',
'Caper',
'Caraway',
'Cardamom',
'Cassia',
'Catnip',
'Cayenne Pepper',
'Celery',
'Chervil',
'Chicory',
'Chili Peper',
'Chives',
'Cicely',
'Cilantro',
'Cinnamon',
'Clary',
'Clove',
'Coriander',
'Costmary',
'Cubeb Pepper',
'Cudweed',
'Culantro',
'Cumin',
'Curry',
'Dill',
'Elderflower',
'Epaztoe',
'Fennel',
'Fenugreek',
'Filé Powder',
'Fingerroot',
'Galangal',
'Galingale',
'Garlic Chives',
'Ginger',
'Golpar',
'Grains of Paradise',
'Grains of Selim',
'Horseradish',
'Huacatay',
'Hyssop',
'Jasmine',
'Jiaogulan',
'Jimbu',
'Juniper Berry',
'Kaffir Lime Leaves',
'Kala Zeera',
'Kawakawa Seeds',
'Keluak',
'Kencur',
'Kinh Gioi',
'Kokam Seed',
'Korarima',
'Koseret',
'Lavender',
'Lemon Balm',
'Lemongrass',
'Leptotes Bicolor',
'Lesser Calamint',
'Licorice',
'Lime Flower',
'Lovage',
'Mace',
'Mahleb',
'Marjoram',
'Mastic',
'Mint',
'Mountain Horopito',
'Musk Mallow',
'Mustard',
'Nigella',
'Nutmeg',
'Olida',
'Oregano',
'Orris Root',
'Pandan Flower',
'Paprika',
'Paracress',
'Parsley',
'Pepper',
'Peppermint',
'Perilla',
'Peruvian Pepper',
'Quassia',
'Rice Paddy Herb',
'Rosemary',
'Rue',
'Safflower',
'Saffron',
'Sage',
'Salad Burnet',
'Salep',
'Sassafras',
'Savory',
'Shiso',
'Sorrel',
'Spearmint',
'Spikenard',
'Star Anise',
'Sumac',
'Sweet Woodruff',
'Szechuan Pepper',
'Tarragon',
'Thyme',
'Tumeric',
'Vanilla',
'Voatsiperifery',
'Wasabi',
'Water-pepper',
'Watercress',
'Wattleseed',
'Wild Thyme', // we are gonna have a
'Willow Herb',
'Wintergreen',
'Wood Avens',
'Woodruff',
'Wormwood',
'Yarrow',
'Zedoary',
];
return function() {
return this.map((_, index) => {
return spices[Math.floor(Math.random() * spices.length)]
});
};
})();
// Credit to @teropa for the idea
// and to @toddmotto for the lexical closure and map
@lucasferreira
Copy link

You can "compact" the things a little more:

  return function() {
    return this.map((_, index) => spices[~~(Math.random() * spices.length)]);
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment