const salutation1 = ["Darling", "Dear", "Honey", "Jewel"];
const salutation2 = ["Duck", "Love", "Moppet", "Sweetheart"];
const adjectives = [
"adorable",
"affectionate",
"amorous",
"anxious",
"ardent",
"avid",
"breathless",
"burning",
"covetous",
"craving",
"curious",
"darling",
"dear",
"devoted",
"eager",
"erotic",
"fervent",
"fond",
"impatient",
"keen",
"little",
"loveable",
"lovesick",
"loving",
"passionate",
"precious",
"sweet",
"sympathetic",
"tender",
"unsatisfied",
"wistful"
];
const nouns = [
"adoration",
"affection",
"ambition",
"appetite",
"ardour",
"charm",
"desire",
"devotion",
"eagerness",
"enchantment",
"enthusiasm",
"fancy",
"fellow feeling",
"fervour",
"fondness",
"heart",
"hunger",
"infatuation",
"liking",
"longing",
"love",
"lust",
"passion",
"rapture",
"sympathy",
"tenderness",
"thirst",
"wish",
"yearning"
];
const adverbs = [
"affectionately",
"anxiously",
"ardently",
"avidly",
"beautifully",
"breathlessly",
"burningly",
"covetously",
"curiously",
"devotedly",
"eagerly",
"fervently",
"fondly",
"impatiently",
"keenly",
"lovingly",
"passionately",
"seductively",
"tenderly",
"winningly",
"wistfully"
];
const verbs = [
"adores",
"attracts",
"cares for",
"cherishes",
"clings to",
"desires",
"holds dear",
"hopes for",
"hungers for",
"is wedded to",
"likes",
"longs for",
"loves",
"lusts after",
"pants for",
"pines for",
"prizes",
"sighs for",
"tempts",
"thirsts for",
"treasures",
"wants",
"wishes",
"woos",
"yearns for"
];
const pick = array => array[Math.floor(Math.random() * array.length)];
const maybePick = array => (Math.random > 0.5 ? `${pick(array)} ` : "");
const getSentence = {
shortest: () => `my ${pick(adjectives)} ${pick(nouns)}`,
short: () => `You are my ${pick(adjectives)} ${pick(nouns)}`,
long: () =>
`My ${maybePick(adjectives)}${pick(nouns)} ${maybePick(adverbs)}${pick(verbs)} your ${maybePick(adjectives)}${pick(nouns)}`
};
const writeLoveLetter = () => {
let sentences = [];
for (let idx = 0; idx < 5; idx++) {
let sentenceType = Math.random() > 0.5 ? "short" : "long";
if (
idx > 0 &&
sentenceType == "short" &&
sentences[idx - 1].type != "long"
) {
sentenceType = "shortest";
}
sentences.push({
type: sentenceType,
words: getSentence[sentenceType]()
});
}
let output = `<p>${pick(salutation1)} ${pick(salutation2)},</p><p>`;
for (let idx = 0; idx < 5; idx++) {
output += sentences[idx].words;
if (idx == 4) {
output += ".";
break;
}
if (
sentences[idx].type != "long" &&
sentences[idx + 1].type == "shortest"
) {
if (sentences[idx].type == "shortest") {
output += ", ";
} else {
output += ": ";
}
} else {
output += ". ";
}
}
output += `</p><p>Yours ${pick(adverbs)}</p><p>M.U.C.</p>`;
$("#love-letter").innerHTML = output;
};
documentReady(() => {writeLoveLetter();})