Skip to main content

Learning about Code Structure

Section 1.15 Rule 3) Remove repeated code and logic from conditional branches

Please watch the video to learn about the third rule (removing repeated code from conditional branches) and then answer the following questions. Enlarge the window to view the code examples clearly. If needed, click the settings icon in the video player and set the quality to 1080p for better clarity.
Figure 1.15.1. Remove repeated code from branches part 1

Activity 1.15.1.

    For the code example discussed in the video, applying which of the following rule(s) resulted in removing the repeated code from the conditional branches?
    Select all that apply.
  • Conjoining conditions with the && operator
  • No. Please watch the video carefully.
  • Conjoining conditions with the || operator
  • Correct!
  • Directly returning boolean conditions
  • No. Please watch the video carefully.
  • None of the rules we’ve learned so far could be applied
  • No. Please watch the video carefully.
You have attempted 1 of 3 activities on this page.