Individual Case Study 4

> Running project readiness diagnostic...

Retro Terminal Project Readiness Checker

This page adds an interactive JavaScript feature to the personal site. The readiness checker uses conditional statements and error handling to review selected project tasks and display a terminal-style status message.

Project Diagnostic

Select the tasks that are complete, then run the diagnostic.

Completed project tasks
> Awaiting diagnostic command...

Debugging Methods Used

For this project, I added exception handling to the Project Readiness Checker form on my personal website. The form asks users to select completed project tasks and then runs a diagnostic that displays a readiness status. I updated the JavaScript so that clicking the diagnostic button with no selected tasks is treated as a user input error.

The code uses a try block to run the diagnostic, a throw statement to create a custom Error object when no tasks are selected, and a catch block to display the error object's message in the diagnostic output area.

try {
    // Run the project diagnostic.
    if (completedTasks === 0) {
        throw new Error("Select at least one completed task before running the diagnostic.");
    }
} catch (error) {
    // Display the custom diagnostic error message.
}

I reviewed the JavaScript and tested the logic with several input cases. First, I tested the diagnostic with no selected checkboxes to confirm that the custom error message appeared. Then I tested one, two, three, and four selected tasks to confirm that the normal readiness messages still worked correctly. This helped verify that the new exception handling did not break the original conditional logic.

I also used the console.log() statement in the script to trace the value of the completed task counter. This helped confirm that the program counted selected tasks correctly before choosing a readiness message or throwing an Error object.

Finally, I kept "use strict"; at the top of the JavaScript file to help catch coding mistakes more reliably. Strict mode makes JavaScript less forgiving of poorly written code, which helps prevent accidental errors such as undeclared variables. Together, strict mode, console tracing, input testing, and exception handling helped confirm that both valid and invalid user input were handled appropriately.