Home For Fiction – Blog

for thinking people

New post every MondayHow not to miss one

javascript

How to Make a JavaScript “Horoscope” Generator

November 10, 2019

Relax, I haven’t gone crazy. If you thought someone like me suddenly started believing in horoscopes, you’re wrong. Yes, in this post I’ll show you how to make a JavaScript horoscope generator. But the post is about linguistics, programming, and maybe psychology; not astrology.

If anything, my goal making this JavaScript horoscope generator was to show how ridiculously easy it is to produce accurate-seeming phrases that appear to apply to everyone’s individual situation. Simple answers to complex questions, really.

There’s actually a bit of literary background in this, believe it or not. There is a scene in my book The Other Side of Dreams, where the protagonist makes fun of a Tarot card reader:

Indeed, Ahmed thought, he could tell Anna pretty much everything the woman had said, without using any cards. “You are coming up a difficult fork in the road of your life, considering your options. Part of you would like to be more daring, but you are aware of the importance of being cautious. You are inspired by strong feelings, and you will be rewarded in love thanks to your tenacity. Remember to be true to yourself, although you should also be diplomatic, especially considering matters related to business, money, or agreements.” There, it can’t get any easier than that.

And so, I decided to combine my background in languages and my interest in programming. This JavaScript horoscope generator was the result!

JavaScript horoscope generator
I promise you, this JavaScript horoscope generator will not tell your fortune – because there is no such thing. Parenthetically, the code you see on the image is part of the actual code used in the program.
(more…)

How to Make a Random Quote Generator

June 5, 2019

Although today’s topic doesn’t have to do with literature, society, the Gothic, or writings tips, in some abstract way, it does. Although this post is a technical step-by-step guide on how to make a JavaScript random quote generator, it’s also yet another reminder that creativity (like knowledge) is a holistic process.

In other words, there aren’t “areas” of creativity, neatly isolated from one another. There isn’t a creativity related to fiction writing, another related to academic writing, and yet another related to developing Android apps. There is only one form of creativity, and the more efficiently you can combine its different facets, the better.

make a random quote generator
To “outsiders” code appears as something akin to witchcraft. Things are stunningly simpler once you get past the surface

Chances are, if you found this post you care more about the JavaScript code, so I won’t tire you with theorizing – if you’re interested in philosophy, feel free to take a look at the many posts dealing with philosophical musings.

Having said that, this post still wants to make a more theoretical point, namely that what appears difficult and incomprehensible (like coding) can be very simple. Therefore, I will be a bit… verbose in my explanations, trying to help beginners keep up.

So, let’s get to the details of how to make a random quote generator written in JavaScript.

(more…)

Anapest Generator: a JavaScript Poem Maker

February 17, 2019

My JavaScript iambic pentameter generator is among the most popular articles on this blog. If you liked that, you’re gonna love today’s article. I decided to make an anapest generator with a rhyme! It’s a JavaScript poetry generator using an anapest, that is, a poem with anapestic meter.

anapest generator
Could the pen really write with the might of the sword?
(see what I did there?) 😉

An anapest, or anapestic meter, is a metrical foot consisting of two unstressed syllables followed by a stressed one. Perhaps the most famous example of an anapestic poem (also mentioned in my article on poetry) is Lord Byron’s “The Destruction of Sennacherib”.

The Assyrian came down like the wolf on the fold,
And his cohorts were gleaming in purple and gold;
And the sheen of their spears was like stars on the sea,
When the blue wave rolls nightly on deep Galilee.

Like the leaves of the forest when Summer is green,
That host with their banners at sunset were seen:
Like the leaves of the forest when Autumn hath blown,
That host on the morrow lay withered and strown.

(more…)