It's like X for Y generator
Created
February 22, 2016 15:18
-
-
Save idmontie/8d8c93255978258a5d82 to your computer and use it in GitHub Desktop.
It's like x for y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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