Sometimes the most satisfying feeling in the world can be that moment when you realize you’ve been going about something all wrong… and then you start over.
I split my weekend between fighting a fever (ie sleeping and drinking lots of water) and trying to teach my computer how to speak Jillian.
It didn’t work.
I was still quite feverish on Sunday night and no matter how many times enunciated to my laptop (in perfectly formed JavaScript) “take whatever text I gave you and reverse the order of the letters in each word while leaving all spaces and symbols in place.” It just kept doing the wrong thing.
.jpg&container=blogger&gadget=a&rewriteMime=image%2F*)
I blame the fever. I know it must’ve been frying my brain ‘cause when I was trying to think of the right adjective to smack talk with my friend at dinner on Saturday night, all I could come up with was “don’t look so… uhm.. .you know that thing where you haven’t seen something before and you’re eyes get wide and stuff? Well, don’t look so that word when I say how impressive I am.”
I wasn’t impressive last weekend though, so maybe that’s why Arthur looked startled maybe he was surprised that I wasn’t up to my usual standards of awesome.
I was patient though. All weekend long I kept plugging along at my code. My stupid code that just didn’t do what it was supposed to.
And then on Monday morning. I woke up and I had an epiphany. “I just need to start the fuck over! What I’m doing doesn’t work!” I wanted to throw my sheets off and run through the streets like Galleo and shout. “I have no fucking clue what I’m doing! I’m starting from scratch! I’m starting from scratch!”
But instead I outlined what I wanted to do. I broke the problem into bite sized pieces and as I found free moments at work and as the night rolled on. I worked away at it… until I finally had a 65 line bohemuth of code that very nearly did what I wanted… so I sent it off to the coding school that had asked me to showcase my brilliance.

And they basically said. “Woooow. This is way too long. You are not asking yourself the right questions.” And I already knew the importance of asking the write questions… the teacher gave me a few tips (which basically equated to step by step instructions on how to actually write the code (and which required that I google for help far more than I’d thought I was allowed.) … and then… a half hour later… Eureka! I had it. I finally got with this program…
var text = prompt("enter some text"); var word = []; var output = "";
for(i=0; i<text.length; i++)
{if (text[i].match(/[a-z]/))
{word.push(text[i]);}
else
{word.reverse();
output += word.join("");
output += text[i];
word = [];} }
console.log (output);

No comments:
Post a Comment