Funny Interaction

// Map, filter, and reduce in Swift, explained with emoji
// https://gist.github.com/AccordionGuy/61716adbf706801e2a496a12ff19526e
// http://devhumor.com/media/map-filter-reduce-explained-with-emoji-s
// http://unicodey.com/emoji-data/table.htm

// Map
function cook(item) {
  let cookupTable = {
    '๐Ÿฎ': '๐Ÿ”', // Cow face -> burger
    '๐Ÿ„': '๐Ÿ”', // Cow -> burger
    '๐Ÿ‚': '๐Ÿ–', // Ox -> meat on bone
    '๐Ÿท': '๐Ÿ–', // Pig face -> meat on bone
    '๐Ÿฝ': '๐Ÿ–', // Pig nose -> meat on bone
    '๐Ÿ–': '๐Ÿ–', // Pig -> meat on bone
    '๐Ÿ‘': '๐Ÿ–', // Sheep -> meat on bone
    '๐Ÿ': '๐Ÿ–', // Goat -> meat on bone
    '๐Ÿ”': '๐Ÿ—', // Chicken -> poultry leg
    '๐Ÿฆƒ': '๐Ÿ—', // Turkey -> poultry leg
    '๐Ÿธ': '๐Ÿ—', // Frog  -> poultry leg (no frog leg emoji...yet)
    '๐ŸŸ': '๐Ÿฃ', // Fish -> sushi
    '๐Ÿ ': '๐Ÿฃ', // Tropical fish -> sushi
    '๐Ÿก': '๐Ÿฃ', // Blowfish -> sushi
    '๐Ÿ™': '๐Ÿฃ', // Octopus -> sushi
    '๐Ÿ ': '๐ŸŸ', // (Sweet) potato -> French fries
    '๐ŸŒฝ': '๐Ÿฟ', // Corn -> popcorn
    '๐ŸŒพ': '๐Ÿš', // Rice -> cooked rice
    '๐Ÿ“': '๐Ÿฐ', // Strawberry -> shortcake
    '๐Ÿ‚': '๐Ÿต', // Dried leaves -> tea
  };
  if (cookupTable[item] != undefined) {
    return cookupTable[item];
  } else {
    return '๐Ÿฝ'; // Empty plate
  }
}

let cookedFood = ['๐Ÿฎ', '๐Ÿ ', 'โšฝ๏ธ', '๐Ÿ”', '๐ŸŒฝ'].map(item => cook(item));
console
  .log(cookedFood) // ["๐Ÿ”", "๐ŸŸ", "๐Ÿฝ", "๐Ÿ—", "๐Ÿฟ"]

  [('๐ŸŒฝ', '๐Ÿฎ', '๐Ÿ”')].map(item => cook(item)); // [ ๐Ÿฟ , ๐Ÿ” , ๐Ÿณ ]

// Filter
function isVegetarian(item) {
  let vegetarianDishes = [
    '๐ŸŸ', // French fries
    '๐Ÿฟ', // Popcorn
    '๐Ÿš', // Cooked rice
    '๐Ÿฐ', // Shortcake
    '๐Ÿต', // Tea
  ];
  return vegetarianDishes.includes(item);
}

let meatFree = ['๐Ÿ”', '๐Ÿ–', '๐ŸŸ', '๐Ÿฝ', '๐Ÿ—', '๐Ÿฟ', '๐Ÿฐ'].filter(item => isVegetarian(item));
console
  .log(meatFree) // ["๐ŸŸ", "๐Ÿฟ", "๐Ÿฐ"]

  [('๐Ÿฟ', '๐Ÿ”', '๐Ÿณ')].filter(item => isVegetarian(item)); // [๐Ÿฟ, ๐Ÿณ]

// Reduce
function eat(previous, current) {
  let qualifyingFood = [
    '๐Ÿ”', // Burger
    '๐Ÿ–', // Meat on bone
    '๐Ÿ—', // Poultry leg
    '๐Ÿฃ', // Sushi
    '๐ŸŸ', // French fries
    '๐Ÿฟ', // Popcorn
    '๐Ÿš', // Cooked rice
    '๐Ÿฐ', // Shortcake
  ];
  if ((previous == '' || previous == '๐Ÿ’ฉ') && qualifyingFood.includes(current)) {
    return '๐Ÿ’ฉ'; // Poop
  } else {
    return '';
  }
}

let aftermath = ['๐Ÿ”', '๐ŸŸ', '๐Ÿ—', '๐Ÿฟ'].reduce((previous, current) => eat(previous, current));
console
  .log(aftermath) // "๐Ÿ’ฉ"

  [('๐Ÿฟ', '๐Ÿณ')].reduce((previous, current) => eat(previous, current)); // ๐Ÿ’ฉ

// http://nomadev.com.br/javascript-emoticons-emojis/
// :man-heart-man:
// :man-woman-boy:
// :man-woman-girl-boy:
'๐Ÿ‘จโ€โค๏ธโ€๐Ÿ‘จ'.replace(/๐Ÿ‘จ/, 'JS'); // "JSโ€โค๏ธโ€๐Ÿ‘จ"
'๐Ÿ‘จโ€โค๏ธโ€๐Ÿ‘จ'.match(/./gu); // ["๐Ÿ‘จ", "โ€", "โค", "๏ธ", "โ€", "๐Ÿ‘จ"]
'๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ‘ฉ'.match(/./gu); // ["๐Ÿ‘ฉ", "โ€", "โค", "๏ธ", "โ€", "๐Ÿ‘ฉ"]
'๐Ÿ‘จโ€โค๏ธโ€๐Ÿ‘จ'.replace(/๐Ÿ‘จ/, '๐Ÿ‘ฉ'); // "๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ‘จ"
'๐Ÿ‘จโ€โค๏ธโ€๐Ÿ‘จ'.replace(/๐Ÿ‘จ/g, '๐Ÿ‘ฉ'); // "๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ‘ฉ"
'๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'.match(/./gu); // ["๐Ÿ‘จ", "โ€", "๐Ÿ‘ฉ", "โ€", "๐Ÿ‘ง", "โ€", "๐Ÿ‘ฆ"]
'๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'.replace(/๐Ÿ‘จ/g, '๐Ÿ‘ฉ'); // "๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ"