'use strict';

const _ = require('lodash');
const adverbs = require('../data/adverbs').adverbs;
const animals = require('../data/animals').animals;
const chars = 'abcdefghijklmnopqrstuvwxyz';

module.exports = createAnAnimalAlliteration;

function createAnAnimalAlliteration(char) {
	char = char || chars.charAt(Math.floor(Math.random() * chars.length));
	char = char.toLowerCase();
	const startChar = char[0];

	const adverb = _.sample(_.filter(adverbs, c => c[0] === startChar));
	const animal = _.sample(_.filter(animals, c => c[0] === startChar));

	if (!adverb || !animal) {
		throw new Error(`Cannot generate a funny alliteration with '${startChar}'! Try some of these: a, b, c`);
	}

	return `${_.capitalize(adverb)} ${_.capitalize(animal)}`;
}

@@ -37,16 +37,77 @@
 dash');%0A
+const adjectives = require('../data/adjectives').adjectives;%0A
 const ad
@@ -150,16 +150,16 @@
 dverbs;%0A
-
 const an
@@ -333,16 +333,27 @@
 ion(char
+, useAdverb
 ) %7B%0A%09cha
@@ -477,16 +477,92 @@
 ar%5B0%5D;%0A%0A
+%09const adjective = _.sample(_.filter(adjectives, c =%3E c%5B0%5D === startChar));%0A
 %09const a
@@ -568,16 +568,28 @@
 adverb =
+ useAdverb ?
  _.sampl
@@ -625,32 +625,37 @@
  === startChar))
+ : ''
 ;%0A%09const animal 
@@ -720,15 +720,44 @@
 if (
-!adverb
+(useAdverb && !adverb) %7C%7C !adjective
  %7C%7C 
@@ -910,16 +910,43 @@
 adverb)%7D
+ $%7B_.capitalize(adjective)%7D
  $%7B_.cap
@@ -962,12 +962,19 @@
 nimal)%7D%60
+.trim()
 ;%0A%7D%0A

add adjectives to output; make adverbs optional via --adverb