Overview

Introduction

Welcome to the Working with JavaScript 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:

1.1 Complete or debug code that uses assignment and arithmetic operators

Lab Duration

It will take approximately 20 minutes to complete this lab.

Exercise 1 - Working with Operators

In a programming language, operators help you to carry out numerical or logical computations. The operators perform computations on operands (variables with values). The operators are available in the form of various symbols. They are categorized into different types based on the nature of computations in the programs. For example, if you want to add two numbers such as 10 and 20, the numbers 10 and 20 are known as the operands. The addition symbol ‘+” is known as the operator.

In JavaScript, the different types of operators are as follows:

  • Arithmetic: The arithmetic operators help to perform numerical calculations such as addition, subtraction, multiplication, division, and finding modulus in scripts.
  • Comparison: The comparison operators help to compare the values of the variables, expressions, or results. These operators are also known as relational operators as they determine the relationship between the operands.
  • Logical: 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.
  • Assignment: The assignment operators are used to assign values to the variables after performing arithmetical operations in numerical expressions or calculations. In this exercise, you will learn how to use the arithmetic and assignment operators in JavaScript. You will learn about comparison and logical operators in the later modules.

You will perform two tasks:

  • Task 1 - You will download the Visual Studio Code workspace (Calculator) from the Intranet and open the HTML page named Calc.html in the Calculator workspace.
  • Task 2 - You will write JavaScript code to use the arithmetic and assignment operators in the calculator application.

Learning Outcomes

After completing this exercise, you will be able to:

Use arithmetic and assignment operators in JavaScript

Comprehensive Learning

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