Project: What Would Dolly Do?

I’ve had this idea brewing for a while and even started on it mid-bootcamp at HackerYou. But once we hit the last few weeks, there simply weren’t enough hours in the day and it was put on the back burner. So once the dust settled and the job hunt began, I dove back into creating a Dolly Parton Quote Generator.


Since there is no Dolly Parton quote API (yet), I created my own array of quotes to pull from.

It was important to me for ease of use to be able to add quotes without having to adjust any of the other code to account for the array length. Math.random generates a number between 0 and 1.0 and then multiplies it by the length of the array (wwdd.myQuotes.length).

wwdd.random = function() {
return Math.floor(Math.random()*(wwdd.myQuotes.length));

I needed a whole number to match up with the corresponding quote from the array, so I used math.floor to round down.

One of the challenging parts of wrapping my brain around JavaScript and jQuery has been adjusting to new syntax. So when using my wwdd.random function in the context of pulling the corresponding quote from my created array, I knew extracting the appropriate property would mean using square brackets.


The above calls my wwdd.random function for a random number within the length of the array. It proceeds to take that number and insert it as the property for the wwdd.myQuotes function. I then use that data to insert that particular quote into the div of my choosing.

While obviously bias in my adoration of all things Dolly, it was a fun way to practice a bit of jQuery and Javascript. In the scheme of things, my coding journey is still in its infancy and seeing this idea evolve into existence and see people use/share/have fun with it was a real highlight.



Leave a Reply

Your email address will not be published. Required fields are marked *