Debugging Javascript (Case)

This is a case study for use in a class like Software Development.

Please note: This case builds on a prior case called ‘Making Stuff Happen with Javascript‘ and assumes familiarity with its contents.

Grinding it Out

Frangelico DeWitt and his team are working on a new suite of software for their employer HVAC in a Hurry (a heating and air conditioning service business). Their current focus is on a web application that helps field technicians find availability and pricing for replacement parts.

Frangelico has been steadily coding and debugging. At the moment, he’s deep in the dev Console, figuring out what’s wrong with his Javascript.

He has a working HTML/CSS prototype on JS fiddle: Javascript Prototype . As a next step, Frangelico needs to get the drop-downs working.

A Series of Small Problems

There are two drop-downs that should allow the user to filter the parts they’re seeing based on either or both of: Manufacturer or Model. They should be able to work independently, and right now neither one is functioning correctly.

Using the Chrome DEVTOOLS (the Console in particular), Frangelico is working through and fixing the issues on the Javascript Prototype. Use whatever process you like to do the debugging EXCEPT comparing this current JS Fiddle to other versions from the associated cases. That is a shortcut that won’t help you with your analytical debugging skills. To get started with the DEVTOOLS, just right click on the page and select ‘Inspect’.

Here’s a general set of steps you may want to consider (for each individual issue):

What line(s) of Javascript is the Console returning errors against, if any? What do you see there. Pro tip: Filter on ‘index’ to see just the content of the JS Fiddle. 

What assumptions are baked into the code? Which ones might be incorrect?

How might you use logging to Console to help you isolate the issue(s)?

You can fork and save the JS Fiddle to preserve your work for the classroom discussion.

Exhibit A: User Stories

These are background to the current list of items in Exhibit B, but as you get into the details it’s key not to lose sight of your core design intent and what you’ve decided is important to the user.

Epic User Story

‘As Ted the HVAC technician, I want to identify a part that needs replacing so I can decide my next steps.’


Based on their observations in the field, Frangelico’s team thought through the user experience of the epic with the following storyboard: hvac-epic-story

Child Stories

User Story

Test Cases

‘I know the part number and I want to find it on the system so I can figure out next steps on the repair.’ Make sure it’s possible to search by part number.
Make sure descriptive info. appears as the search narrows (photo?) to help avoid error.
‘I don’t know the part number and I want to try to identify it online so I can move the job forward.’ Make sure it’s possible to search by make/model of units
Make sure it’s possible to search by type
‘I don’t know the part number and I can’t determine it and I want help so I can move the job forward.’ Make sure an estimate of the turnaround time for an expert to review is available
‘I want to see the cost of the part and time to receive it so I decide on next steps and get agreement from the customer.’ Make sure it’s possible to dispatch a request by email to the customer in case they order their own parts and/or carry their own inventory of spares.
NOTE: How would the customer respond so we can help structure the next steps as we would otherwise?
Make sure it’s possible to indicate priority
Make sure cost associated with priority delivery are available
‘I want to order the part so that we can move forward with the repair.’

Exhibit B: Working with the Sample Code on JS Fiddle

The basic idea with JS Fiddle is that you can quickly write and test your code in a simplified environment. When you arrive at the sample JS Fiddle, you can freely edit it.

If you want to see your changes in the ‘Results’ pane, you’ll need to click the ‘Run’ button at the top.

If you want to save your version, you’ll need to have an account on JS Fiddle and click ‘Save/Update’.

Exhibit C: Using the Chrome DEVTOOLS

The Chrome DEVTOOLS tutorials are pretty good and quite short. I recommend checking out–
Inspect and Debug Javascript

There are even small practice exercises for you to use in-context as a warm-up. A few things I would be sure you can do by the end of reviewing these and applying them in the case (or wherever you like):

  1. Viewing output to the Console. If you add a console statement to the code, do you see its output in the Console?
  2. Are you able to find and review the lines of JS the Console identifies (just click on the link it shows to the right)?
  3. Setting a breakpoint in the code and adding variables to the Watch Expressions to see their values. Are you able to observe the values?

Note: There is another item related to the Console called ‘Using the Console’, but I think you’ll find everything you need in the section above. That said, of course feel free to check it out if it interests you.