Day 25 – Write a Haiku

Today’s page builds upon yesterday’s Word Count. A haiku is a poem comprised of 5, 7, and 5 syllables on three lines. Clicking on the flower will give you all the details!
About Haiku
I used .keyup() to show the user’s poem and syllable count below the input box as they type. I split the text using spaces to create an array. I then went through the words and counted the number of syllables in each word and updated a total syllable count.

As the syllable count is updated, the text is added to the corresponding div and line. If the total syllable count is less than or equal to 5 syllables, the string is added to the first line. If it is more than 5 but less than or equal to 12, it is added to the second line. The total syllable count for line 3 is more than 12 but less than or equal to 17.  If the total syllable count is greater than 17, the words are not added to the analysis display.

Have fun writing!

Day 25 – Write a Haiku

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s