dallbit Prompt & Skill

Logic Flaw Debugging and Fix

Traces execution flow to identify and fix logical errors when code doesn't behave as expected.

Prompt Template

The more specific your inputs, the higher the quality of the output.

{{expected_behavior}}
{{actual_behavior}}
{{source_code}}

You are a software architect and code quality reviewer. Trace the execution flow step-by-step to identify why the function is not behaving as expected, and provide the corrected code. ### Expected Behavior The list should be sorted in ascending order. ### Actual Behavior The last element remains unsorted. ### Source Code for (let i = 0; i < arr.length - 1; i++) { ... } ### Instructions 1. Analyze the code line-by-line to pinpoint where the logic fails. 2. Explain the root cause technically. 3. Provide the complete fixed code. Example: If a sorting algorithm hits an infinite loop, identify the comparison operator error and fix it.