Friday Puzzler

I thought the last puzzler was kind of fun, so I figured why not do it again. I’m not around much today to comment on the entries, but if you are bored, here is a small coding challenge: Madlibs. Your code will take a hard coded string like so:

Four score and {number} years ago,
Star Wars was a {adjective} movie.
I saw it with two hundred {plural noun}.
I need a new {noun} like I need a new {noun} in my head.

It will look for any tokens inside { } characters, and create a simple form where the value inside the {} token is the label for the text field. In other words, the string above would have made a form with three text fields, labelled number, adjective, and plural noun. When the user hits submit, the values for each form field will replace the tokens in the original string.

Nice and simple, right? Don’t even bother with validation. Just parse the string, create the form, and then display the madlib based on the user’s input.

As a reminder, this is not a contest. There are no prizes. If you spend more than five minutes on it, walk away from your computer. Enjoy.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments