Skip to content

Instantly share code, notes, and snippets.

@idmontie
Created February 22, 2016 15:18
Show Gist options
  • Save idmontie/8d8c93255978258a5d82 to your computer and use it in GitHub Desktop.
Save idmontie/8d8c93255978258a5d82 to your computer and use it in GitHub Desktop.
It's like x for y

It's like X for Y generator

<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="idea"></div>
<button>New idea please</button>
</body>
</html>
let things = [
'tinder',
'facebook',
'youtube',
'vine',
'ebay',
'amazon',
'robinhood',
'agario',
'headphones',
'twitter',
'tumblr',
'pinterest',
'meetup',
'linkedin',
'wordpress',
'soundcloud',
'asana',
'virtual reality',
'chipotle'
'augmented reality',
'google',
];
let nouns = [
'cats',
'dogs',
'frogs',
'woodlands creatures',
'ants',
'Mitt Romney',
'kids with braces',
'Obama',
'wizards',
'Kim Jung Un',
'prisoners',
'mythical sea creatures',
'lizards',
'teachers',
'small farm animals',
];
let randomPick = (arr) => {
return arr[Math.floor(Math.random() * arr.length)];
}
let maybeExtension = (arr) => {
if (Math.random() > 0.5) {
return ' meets ' + randomPick(arr);
} else {
return '';
}
}
$('button').click(function (e) {
e.preventDefault();
let idea = 'It\'s like ' + randomPick(things) + maybeExtension(things) + ' for ' + randomPick(nouns);
$('.idea').text( idea );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment