Lorem CardiBsum

October 01, 2021

I love Lorem Ipsum generators. This one in particular is my favorite because I adore Futurama.

I also happen to love Cardi B. I stand behind my music choices— there are no disclaimers about questionable taste here. Cardi B rules. I used to have her play in the background while putting on makeup right before my bar shifts; She just knows how to make a girl feel like a bad bitch who isn’t going to let drunk patrons bully her, you know? Cardi B is an audio confidence boost.

Anyways, between my love of alternative Lorem Ipsum text and Cardi B, the next natural step was to make a super simple generator that slaps together Cardi B lyrics and prints it out into the console for my own entertainment. Here are the results:

screenshot of the console

Here is the github link.

The actual bits of code are very similar to my last project.

readFile('cardi-b-lyrics.txt', { encoding: "utf8" }, (err, data) => {
  if (err) throw err;

  let lyricLines = data.split("\n")
  function getLyricBits() {
    let randomLine = lyricLines[Math.floor(Math.random() * lyricLines.length)]
    return randomLine

Here, we have readFile to go through a text file of some copy pasted Cardi B lyrics.

We then separate the lyrics by the line. It’s now a large array of strings, so in order to select a random line, we access an index via Math.floor(Math.random() * lyricLines.length).

Math.random will give you some decimal number between 0 and 1, and then multiplying it by the total of lyric lines will bring that decimal number up to a whole number, no larger than however many lyric lines there are. (Basically, it sets a maximum!) At this point, the result gets fed to Math.floor, which will take the integer and ditch the rest.

  function generateText() {
    let paragraph = "";
    let totalWords = 500;
    while (paragraph.length < totalWords) {
      paragraph = paragraph.concat(getLyricBits() + ". ");
    return paragraph;

Here, we set the length of the generated text to be about 500 characters. calling getLyricsBits grabs a random line from the array, and before it gets concatenated onto paragraph, I add a period and a space.

Aaaaand that’s it! Super simple. I’m definitely irrationally entertained by this. It got a few chuckles out of my partner too, who doesn’t have the same excellent taste in music that I have.