import {List, Map} from 'immutable';

export function setEntries(state, entries) {
  return state.set('entries', List(entries));
}

export function next(state) {
  const entries = state.get('entries');
  return state.merge({
    vote: Map({pair: entries.take(2)}),
    entries: entries.skip(2)
  });
}

export function vote(state, entry) {
  return state.updateIn(
    ['vote', 'tally', entry],
    0,
    tally => tally + 1
  );
}

@@ -193,16 +193,54 @@
 ntries')
+.concat(getWinners(state.get('vote')))
 ;%0A  retu
@@ -459,12 +459,418 @@
  + 1%0A  );%0A%7D%0A
+%0A// PRIVATE FUNCTION%0A// should only be called within next() function%0Afunction getWinners(vote) %7B%0A  if (!vote) return %5B%5D;%0A  const %5Ba, b%5D = vote.get('pair');%0A  const aVotes = vote.getIn(%5B'tally' a%5D, 0);%0A  const bVotes = vote.getIn(%5B'tally' b%5D, 0);%0A  if (aVotes %3E bVotes) %7B%0A    return %5Ba%5D;%0A  %7D else if (aVotes %3C bVotes) %7B%0A    return %5Bb%5D;%0A  %7D else %7B%0A    // Handles tied vote condition%0A    return %5Ba, b%5D;%0A  %7D%0A%7D%0A

Add 'getWinners()' functin