Working with Break and Continue Statements

Practice Labs Module
Time
18 minutes
Difficulty
Intermediate

Welcome to the "Working with Break and Continue Statements" Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.

Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Overview

Introduction

Welcome to the Working with Break and Continue Statements Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.

Exam Objectives

The following exam objective is covered in this lab:

  • 3.3 Complete and debug loops

Lab Duration

It will take approximately 10 minutes to complete this lab.

Exercise 1 - Working with Control Flow Statements

The control flow statements in loops help to shift the flow of code execution at run-time. In JavaScript, there are two types of control flow statements such as break and continue.

In switch-case, the break statement is used to come out of the case condition. Similarly, in loops, the break statement is used to break the loop completely. The control comes out of the loop and shifts to the next statement outside the loop body.

The continue statement forces the program to terminate the execution of the current iteration within a loop if the condition is true. It tells the interpreter to recheck the condition from the beginning of the loop and continue the execution. After the loop is executed completely, the control comes out of the loop, and shifts to the next statement outside the loop body.

In this exercise, you will learn to use the control flow statements such as break and continue in loops. You will perform the following tasks:

  • Task 1 - You will download the Visual Studio Code workspace (ComputeGrade) from the Intranet and open the HTML page named Grade.html in the ComputeGrade workspace.
  • Task 2 - You will write JavaScript code to add for/in loops with break and continue statements in Grade.html.

Learning Outcomes

After completing this exercise, you will be able to:

  • Use the control flow statements in JavaScript
Learning Partner
Comprehensive Learning

See the full benefits of our immersive learning experience with interactive courses and guided career paths.