Silly story generator | MDN JavaScript Guide
Live preview of the end result.
Source and references:
Condition of the task
In this assessment you’ll be tasked with taking some of the knowledge you’ve picked up in this module’s articles and applying it to creating a fun app that generates random silly stories. Have fun!
Solutions
-
The file silly_story_generator.main.v.1.init.js is created by following the steps provided at the Silly story generator assessment (exercise).
-
The file silly_story_generator.main.v.2.reusable-template-literals.js is a little bit improved version that uses reusable template literals function with arrow syntax.
const storyTextFn = (x, y, z) => `It was 94 fahrenheit outside, so ${x} went for a walk. When they got to ${y}, they stared in horror for a few moments, then ${z}. Bob saw the whole thing, but was not surprised — ${x} weighs 300 pounds, and it was a hot day.`; // ... let newStory = storyTextFn(xItem, yItem, zItem);