I decided to write a program that pieced together pseudo-haikus from supplied strings. By “pseudo-haiku”, I am referring only to a short poem that fits the 5-7-5 syllable structure and not accounting for whether the content makes sense.
Writing the program was straightforward and I believe I did it in the most basic way possible. Altogether, it probably took about 45 minutes to get it to the state in which it is currently in. Coming up with the strings for the arrays took more time than I intended, but I think I worried about that part too much.
Overall, I am glad to see that it worked and am interested to see the other users’ implementations.
GitHub repository link
Looks neat! One way you could improve further is by remembering the DRY rule (Don’t Repeat Yourself). At the end of your code you have:
How about writing a second function with a loop that will generate these three console logs? You could also put each array
lastFive inside one array:
let array1 = [1,2];
let array2 = [3,4];
let array = [array1, array2]; // [[1,2],[3,4]]
console.log(array); // logs 3
Yeah, I was not satisfied with the repeated lines, but I wanted the output to be three lines. I probably should have looked for a newline character that would have accomplished the same thing that I had with one console.log command.
Thank you for your suggestion.
I really like the concept. Its a bit of fun. You could have packaged it all up in an object and used methods. The structure might have helped you to stay dry.
Something like the randomMenu builder project would have worked as a model.
Still very cool idea