A simple JavaScript application, that I was create while I was learning JavaScript promises.
The initial task: Simple Joke Apps.
The current implementation provides much more functionalities, including: 1) Typewriter effect with sound; 2) DOM element to image implementation; 3) Session records of the fetched jokes; 4) Local storage for the user preferences; 5) Dynamic fetch of all resources; 6) Auto play feature; and more.
There are two variants of the main.js
file. The only difference is within the main Joke.prototype.jokeType()
method:
-
main-one-speed-param.js
has a single parameter for a single character write time (speed) - it uses the following code to loop over the text.[...text].forEach((char, index, array) => { setTimeout(() => { typeSingleCharacter(char, index, array) }, index * speed); });
-
main-two-speed-params.js
has two parameters for a single character write time (speed), one for the character write itself and one for a delay after that - it uses the code below to loop over the text, respectively the functiontypeSingleCharacter()
is modified to work with promises.for (const index in text) { await typeSingleCharacter(text[index], index, text); }
Additional references: