join-media.js 467 B

1234567891011121314151617
  1. "use strict"
  2. module.exports = function(parentMedia, childMedia) {
  3. if (!parentMedia.length && childMedia.length) return childMedia
  4. if (parentMedia.length && !childMedia.length) return parentMedia
  5. if (!parentMedia.length && !childMedia.length) return []
  6. const media = []
  7. parentMedia.forEach(parentItem => {
  8. childMedia.forEach(childItem => {
  9. if (parentItem !== childItem) media.push(`${parentItem} and ${childItem}`)
  10. })
  11. })
  12. return media
  13. }