Working with Logical Operators
Welcome to the "Working with Logical Operators" Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.
Already have an account? Sign In »

Introduction
Welcome to the Working with Logical Operators 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.1 Evaluate expressions that use logical and comparison operators
Lab Duration
It will take approximately 15 minutes to complete this lab.
Exercise 1 - Working with Logical Operators
The logical operators help to arrive at decisions under specific conditions. These operators return a value of either true or false based on the conditions in the programs.
The “&&” operator is used to compare the values in an expression. Consider an example where there are two conditions in the expression such as a>b and b<a. If the result of both conditions is true, the entire expression’s result is true. Else, the result is false.
The “||” operator is also used to compare the values. Consider an example where there are two conditions in the expression such as a>b and b>a. If the result of any one condition is true, the entire expression’s result is true. Else, the result is false.
The “!” operator is used to arrive at the result. It reverses the result of the condition. For example, if the value of the condition a>b is true, the reversed value will be false. The reversed value is the result of the logical operation using the “!” operator.
In this exercise, you will perform two 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 use the logical operators such as and, or, and not.
Learning Outcomes
After completing this exercise, you will be able to:
- Use the logical operators in JavaScript
See the full benefits of our immersive learning experience with interactive courses and guided career paths.