When debugging a program, a situation often arises where it is necessary to trigger a breakpoint only if the variable contains a certain value. Very often this situation arises in the loop. Let's look at an example and learn how to put a breakpoint on a certain condition. There is a 'persons' array. In the loop, we go through this array and display the first and last names in the console. I set a breakpoint inside the loop, but we need the breakpoint to work only if the person's last name is 'Brown'. Let's see how to do it:
Step 1 - Set Regular Breakpoint
Click to open in a new tab
Step 2 - Right Click on Breakpoint
Click to open a new tab
Step 3 - Set Conditional Breakpoint
Click to open in a new tab.
Step 4 - Run App
Click to open in a new tab.