I’m a big fan of The Big Bang Theory and I couldn’t resist playing around with Sheldon’s friendship algorithm. It’s pretty much one object represented as
Sheldon guided by the module pattern (thanks to Addy Osmani).
I encourage you to fork this code and get some zen coding in. Since the logic is “safely” protected by
Sheldon, you should be able to integrate any boilerplate of your choice for some fun interfaces. Also, feel free to refactor the logic when needed. It could always be better. That said, kudos to Wolowitz for plotting out the loop counter and escape.
To demo this in real-time, pop open your browser’s dev tool, navigate to the console and run:
//Open your console right now and run this. Sheldon.ask();