Googling for code solutions can be tricky — here's how to get started

Mad Libs was driving me mad.

In order to learn JavaScript earlier this quarter, I set out to build a web application that would mimic a game of Mad Libs and immediately got stuck. The idea was that the game would prompt you to enter a set of random words according to specific parts of speech, and then return to you a story whose blanks had been filled in with those words. Cue a hilarious mix match of sentences.

In theory, building it would be simple: have an input form in which the user entered various words. With a button click, my code would hide the form, and show the story template with its blanks populated with the input values.

But none of it was working. I needed my code to rewrite the HTML with the resulting story, but It. Just. Wouldn’t. Do it.

Unfortunately, you can’t Google “my Mad Libs project isn’t working,” or even, “rewrite HTML with resulting story like in Mad Libs.”

Often, especially for an inexperienced coder like me, the trouble with tackling projects with an infinite number of methods (as with JavaScript) is that you don’t necessarily know what the language can or can’t do. So you just have to cross your fingers and hope that Google will fetch the answer to the annoyingly contextual problem you have before you can even articulate what specific action you want the code to carry out.

For my MadLibs project, no permutation or combination of the words “input values into text,” “populate template,” “rewrite HTML” was giving me the answer I wanted, so I took to Twitter:

Half an hour later, Timothy Kempf, a developer in California, took kindly to my tweet of desperation and asked what kind of problems I was having. After going back and forth on Twitter, he offered to look over a Gist (Warning: Code may make your eyes bleed) of my code, and left comments for how I could fix it. I had my Eureka moment then. I was telling the JavaScript to run as soon as the document loaded, not necessarily within the workflow of my submit button, which rendered it unusable. My immediate problem was solved, but I knew I couldn’t always rely on a real, experienced developer to look over my shoddy code every time it didn't work. So instead, I took a step back and asked myself: How do the pros do it? I asked Jeremy Bowers, a news applications developer at NPR, who said he follows a specific pattern when Googling to achieve specific outcomes:

e.g. “JavaScript remove key from object”

What a deceivingly simple pattern. Like code, which I’ve learned is better simple than complex, Google searches should be simple, but broad enough to bring you the anticipated results.  Sadly, my problem was that I didn’t even know how to get to the level of correct specificity.

I next turned to Nick Bennett, a Chicago-based developer, who suggested that I  “search to find better search terms.” I myself had been doing this, but failed to recognize the pattern in my habits:

Mine the diamonds in the rough, Bennett said. “There’s nothing wrong with going to page 10+ of search results.”

Alternatively (and perhaps additionally), Kempf suggested you check the console. (For new coders, that’s the box that pops up when you right click + “Inspect Element” in Google Chrome.)

“Odds are, if what you’re doing isn’t working, it’s thrown an error somewhere,” he said. “If you’re having trouble finding out where something is mysteriously dying, you might want to start logging things until you can track down the issue.”

Lucky for us, Google has a tutorial on how to use the console for debugging JavaScript, which, I’m sure, you can apply to other languages.

The great thing about the console is that it shoots you an error message that you can also Google.

When all else fails, learn the vocabulary, Kempf said. That might mean an extra 20 minutes on a sidetrack perusing the documentation and perhaps  shaving a yak. But ideally, it’ll help you recall other things you’ve heard or read and eventually help refine your searches earlier.

“If you see an error, don’t just fix it,” he said. “While you might be able to solve a problem by copying and pasting from Stack Overflow, the best way to use it is to understand why the problem happened, and how the solution works.”

Of course, if that Gist was any hint, my code had a couple dozen more problems to address. For longer than I’d like to admit, I ran line by line, figuring out each Google query and error message as I went. I rephrased my questions as I picked up new lingo, following Bennett’s advice of using my search results to come up with better search terms. When an error message popped up, I did my best to understand why my code hated me, and how I could fix our tumultuous relationship.

I eventually did finish my Mad Libs project, which helps you come up with a ridiculous excuse for not going into work.  It may come in handy, especially the next time I spend too long trying to figure out how to Google when I don’t know what to Google.

About the author

Suyeon Son

Undergraduate Fellow

Latest Posts

  • Introducing StorylineJS

    Today we're excited to release a new tool for storytellers.

    StorylineJS makes it easy to tell the story behind a dataset, without the need for programming or data visualization expertise. Just upload your data to Google Sheets, add two columns, and fill in the story on the rows you want to highlight. Set a few configuration options and you have an annotated chart, ready to embed on your website. (And did we mention, it looks great on phones?) As with all of our tools, simplicity...

    Continue Reading

  • Join us in October: NU hosts the Computation + Journalism 2017 symposium

    An exciting lineup of researchers, technologists and journalists will convene in October for Computation + Journalism Symposium 2017 at Northwestern University. Register now and book your hotel rooms for the event, which will take place on Friday, Oct. 13, and Saturday, Oct. 14 in Evanston, IL. Hotel room blocks near campus are filling up fast! Speakers will include: Ashwin Ram, who heads research and development for Amazon’s Alexa artificial intelligence (AI) agent, which powers the...

    Continue Reading

  • Bringing Historical Data to Census Reporter

    A Visualization and Research Review

    An Introduction Since Census Reporter’s launch in 2014, one of our most requested features has been the option to see historic census data. Journalists of all backgrounds have asked for a simplified way to get the long-term values they need from Census Reporter, whether it’s through our data section or directly from individual profile pages. Over the past few months I’ve been working to make that a reality. With invaluable feedback from many of you,......

    Continue Reading

  • How We Brought A Chatbot To Life

    Best Practice Guide

    A chatbot creates a unique user experience with many benefits. It gives the audience an opportunity to ask questions and get to know more about your organization. It allows you to collect valuable information from the audience. It can increase interaction time on your site. Bot prototype In the spring of 2017, our Knight Lab team examined the conversational user interface of Public Good Software’s chatbot, which is a chat-widget embedded within media partner sites.......

    Continue Reading

  • Stitching 360° Video

    For the time-being, footage filmed on most 360° cameras cannot be directly edited and uploaded for viewing immediately after capture. Different cameras have different methods of outputting footage, but usually each camera lens corresponds to a separate video file. These video files must be combined using “video stitching” software on a computer or phone before the video becomes one connected, viewable video. Garmin and other companies have recently demonstrated interest in creating cameras that stitch......

    Continue Reading

  • Publishing your 360° content

    Publishing can be confusing for aspiring 360° video storytellers. The lack of public information on platform viewership makes it nearly impossible to know where you can best reach your intended viewers, or even how much time and effort to devote to the creation of VR content. Numbers are hard to come by, but were more available in the beginning of 2016. At the time, most viewers encountered 360° video on Facebook. In February 2016, Facebook......

    Continue Reading

Storytelling Tools

We build easy-to-use tools that can help you tell better stories.

View More