Manipulating Strings

Practice Labs Module
Time
18 minutes
Difficulty
Intermediate

Welcome to the "Manipulating Strings" 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 Manipulating Strings 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:

2.1 Declare and use variables of primitive data types

Lab Duration

It will take approximately 30 minutes to complete this lab.

Exercise 1 - Working with Strings

The string data type stores a single character or a set of characters. At times, you may need to work with the string values in programs extensively. JavaScript provides you with the flexibility to manage strings. There are various built-in methods and properties that enable you to format, replace, join, extract, and search strings. These methods and properties do not modify the original string values. The methods return a new string as the output. Strings are immutable, in other words, the original values of the strings in JavaScript programs cannot be changed. The string related methods can only replace the original string value.

In this exercise, you will perform two tasks:

  • Task 1 - You will download the Visual Studio Code workspace (Calculator) from the Intranet and create a new HTML page named Manipulatestr.html in the Calculator workspace.
  • Task 2 - You will write JavaScript code to use the built-in string methods and properties to work with the string values. Some of the built-in methods that you will learn in this exercise are search(), indexOf(), lastIndexOf(), slice(), substring(), substr(), replace(), concat(), and charAt(). You will also learn about the string length property.

Learning Outcomes

After completing this exercise, you will be able to:

Use the built-in string methods and properties to work with strings

Learning Partner
Comprehensive Learning

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