My JavaScript iambic pentameter generator is among the most popular programming posts on Home for Fiction. It’s a really “alpha” piece of code which I haven’t worked on since I made that first version. But here’s a little something to compensate: let’s make a rhyming JavaScript Shakespearean sonnet mixer!
Unlike the iambic pentameter generator, this JavaScript Shakespearean sonnet mixer returns much more coherent results. After all, the code doesn’t need to generate any random text. It simply shuffles the Bard’s own production.
For a relevant project, also take a look at my poem shuffler.
To keep things simple, I decided to have it generate only two rhyming lines. The more the lines, the slower it would get – and the more likely it would not find any rhyming pairs.
(more…)