function combineDecks(...lists) {
    const combinedList = [];
    lists.forEach(function (list) {
      list.forEach(function (card) {
        let inCombinedList = false;
        for (var i = 0; i < combinedList.length; i++) {
          if (card['n'] === combinedList[i]['n']) {
            inCombinedList = true;
            break;
          }
        }
        if (inCombinedList) {
          combinedList[i]['q'] += card['q'];
        } else {
          // deep clone object when adding to list to avoid pointer issues when
          // incrementing its size if it is duplicated
          combinedList.push(Object.assign({}, card));
        }
      });
    });
    return combinedList;
  }
// combines any number of decks into one deck (combines quantities for duplicate entries)
combines any number of decks into one deck (combines quantities for duplicate entries)
combines any number of decks into one deck ( combines quantities for duplicate entries )
function combineDecks(...lists) {
    const combinedList = [];
    lists.forEach(function (list) {
      list.forEach(function (card) {
        let inCombinedList = false;
        for (var i = 0; i < combinedList.length; i++) {
          if (card['n'] === combinedList[i]['n']) {
            inCombinedList = true;
            break;
          }
        }
        if (inCombinedList) {
          combinedList[i]['q'] += card['q'];
        } else {
          combinedList.push(Object.assign({}, card));
        }
      });
    });
    return combinedList;
  }
function combineDecks ( ... lists ) { const combinedList = [ ] ; lists . forEach ( function ( list ) { list . forEach ( function ( card ) { let inCombinedList = false ; for ( var i = 0 ; i < combinedList . length ; i ++ ) { if ( card [ 'n' ] === combinedList [ i ] [ 'n' ] ) { inCombinedList = true ; break ; } } if ( inCombinedList ) { combinedList [ i ] [ 'q' ] += card [ 'q' ] ; } else { combinedList . push ( Object . assign ( { } , card ) ) ; } } ) ; } ) ; return combinedList ; }
combines any number of decks into one deck (combines quantities for duplicate entries)
combines any number of decks into one deck ( combines quantities for duplicate entries )
// deep clone object when adding to list to avoid pointer issues when // incrementing its size if it is duplicated