import Random from '../util/random';
import countries from '../data/countries';

export const QUIZ_OPTIONS_COUNT = 5;

export const generateQuizOptions = (num = QUIZ_OPTIONS_COUNT) => {
  const options = Random.getRandomRange(countries, num);
  const answer = Random.getRandomRange(options, 1)[0];
  return {
    options,
    answer
  }
}

import Random from '../util/random';
import countries from '../data/countries';

export const QUIZ_OPTIONS_COUNT = 5;

let queue = [];

export const generateQuizOptions = (num = QUIZ_OPTIONS_COUNT) => {

  if (queue.length > countries.length * .2) {
    queue = queue.slice(1);
  }

  const options = Random.getRandomRange(countries.filter(country => queue.indexOf(country.iso3) === -1), num);
  const answer = Random.getRandomRange(options, 1)[0];

  queue.push(answer.iso3);

  return {
    options,
    answer
  }
}

Add answers to a cooldown queue
Add answers to a cooldown queue
