And the topic for this month’s blog is…drumroll please…JavaScript.

SFX: Crickets.

I got nothin’.

The End.

Okay, okay…I’m sure I have something to offer on this intensely awesome topic. Just focus. Mmmmkay…it’s pretty much just organizing information. Everybody needs that, right? I do that every day as a writer. Taking abstract ideas and piles of information and weeding it down to bits and pieces of direction.

It’s like creating an outline for a good book and then adding layers within layers of descriptive information. First the chapters. Then the pages. Then the characters. Next, describing the many quirks of the characters. Now, add the details of their stories. See, this isn’t so hard!

So what is my book about?

1. I’ll start by listing some nifty chapter titles…

Childhood Memories. Good, good.

Surviving High School. Yes. Even better.

Adventures in Adulthood. That’ll hook ‘em.

Now, how would all this look if I were presenting these book chapters online, say in a JavaScript one-dimensional array? It goes a little something like this:

var chapterList = []; // create the array

// now hit me with your best shot

chapterList[0]=”ChildhoodMemories”;

chapterList[1]=”SurvivingHighSchool”;

chapterList[2]=”AdventuresinAdulthood”;

I’m sweating a little but that wasn’t so bad, was it? It’s like when I was learning to hook up sound equipment for the first time. Scary, but once you do it a few times you’re like, that awesome sound is coming from the system that I set up. Pat on the back. Now, just don’t blow a speaker.

2. Next, let’s tackle the book pages.

We’ll just work with Chapter 1: Childhood Memories for the sake of this blog. My section headings are:

Kindergarten Cops & Karate Chops

Feathered Bangs & Beauty School Dropouts

Graduation Ham

I know you can’t wait to read these. But first we need to organize the sections so they look right on the Web. Here’s where two-dimensional arrays step in to help us out:

var Chapter 1= []; // create the array of sections

Chapter One[0] = []; // create a nested array

Chapter One[0][0] = “Kindergarten Cops & Karate Chops”;

Chapter One[0][1] = “Feathered Bangs & Beauty School Dropouts”;

Chapter One[0][2] = “Graduation Ham”;

Are you getting curious about my book yet?

3. Let’s get those characters in for a callback.

Callbacks help you in defining the characters of each story. For example, my characters are drawn from real life experiences and take on personalities all their own. They are:

Kindergarten Boys – Attention-getting, havoc-wreaking great balls of energy acting out behind the teacher’s back.

Beauty School Dropouts – “So-called” beauticians practicing haircuts on small children.

Graduation Ham – The international graduation deli meat of choice.

We can give the characters functions too. Often we use the return value of one function to give another function context or variables to work with.

// define a function named creating

// accept a parameter of what to characters

// also accept a callback function to call when we’re done

function creating (characters, callback) {

callback(“creating ” + characters); // returns this value to the callback

}

// call creating() the item “characters”

// when that function finishes it gives its return to the parameter greeting

creating (“characters”, function (action) {

// then do something more with what you received

console.log(action + “Want to read my story?”); // “Creating characters. Want to read my story?”

});

4. Recursion of quirkiness.

When it comes to JavaScript, think of recursion as a listing of quirky characteristics within each character like this:

Kindergarten Boys – clingy; terrorizing; may have “cooties”

Beauty School Dropouts – scissor wielding amateurs; chopped locks; crooked bangs

Graduation Ham – slimey; shiny; white fatty chunks shaped like eyes staring into my second-grade soul

We’ll use Graduation Ham…’cause it’s so divine…

// accepts one parameters; data

// data is a json element or array of json elements

function iterate(GraduationHam) {

var result = “”; // what we will eventually return

// for each identifier key in the data

for (ham in quirksofGraduationHam) {

// if it is a javascript object, aka json

if (quirksofGraduationHam[ham] === ‘object’) { //

GraduationHam[ham]’s value is an object

// then repeat this process with the new value

iterate(quirksofGraduationHam[ham]); //

// then repeat this process with the new value over and over again

} else { // otherwise do this

result += ‘n’ + book + “: ” + (quirksofGraduationHam[ham] ; // write it to

a string

}

}

return result; // Graduation Ham – slimey; shiny; white fatty chunks shaped like eyes staring into my second-grade soul

}

Now, I really am scared. But I can’t do it alone. Most people don’t get JavaScript either, so you’ll need to seek out help from a professional….computer scientist or coder, that is. Recursion is great because it simply helps you create a linked list.

5. The juicy details.

So you made it to the end. It’s a lot to take in, right? So what’s all this fuss about ham? I won’t make you wait any longer. By presenting my memoirs online you’ll be able to enjoy:

Kindergarten Cops & Karate Chops – Stories about the kindergarten boys causing a general ruckus. Chasing us girls on the playground until we cried to the “cops” for mercy. Hosting karate matches, while our teacher was out of the room, and watching the boys’ shoes fly across the floor when “Daniel-son” does his infamous crane kick. Then racing back to our desks hoping the shoes won’t give us away when the teacher steps back in.

Feathered Bangs & Beauty School Dropouts – Just like it sounds, we’ve all had that bad haircut that is burned in our brains for all time, and into our photographs. You may even still have a schoolhouse picture frame displaying each year of increasing embarrassment.

Graduation Ham – With my dad being a teacher for 42 years, I attended my fair share of grad celebrations as a young girl. So yes, I can write a dissertation on the topic of graduation ham and its scary, pearlized deli sheen staring at me from the party platter across the room.

Need I say more?

As far as displaying these stories online, JavaScript DOMs will allow you to search each different story detail. Like this:

document.querySelector(“.story”); // query for one element of class story

document.querySelectorAll(“.details”); // an array of all elements of class details

Now, I’m not sure if this blog inspires you to learn more about JavaScript or just wait with bated breath for more stories about ham. But in all seriousness, hopefully I’ve captured your attention for a moment to help simplify what JavaScript can do for you. And if so, my work here is done.

Hungry for more light-hearted coding info? Check out how you can start drinking in the morning – JavaScript style.