Overview

Introduction

Welcome to the Sorting and Searching Single-Dimensional Arrays 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.2 Declare and use arrays

Lab Duration

It will take approximately 20 minutes to complete this lab.

Exercise 1 - Working with Single-Dimensional Arrays

Assume a situation in an application where you want to sort the array elements, search for a particular element, or join all the elements. You can do all these tasks with the help of various built-in array methods. These methods help to perform various operations on single-dimensional arrays such as sorting, searching, joining, reversing, etc.

The sort() method helps to sort the array in ascending order. The reverse() method reverses the elements in an unsorted array. This method sorts the elements in descending order in a sorted array. The find() method searches the required element in an array. The join() method joins the array elements. However, these built-in methods will not modify the original array elements.

In this exercise, you will learn to perform various operations such as sorting, reversing, searching, converting, and joining single-dimensional array elements. You will perform the following tasks:

  • Task 1 - You will download the Visual Studio Code workspace (StudentList) from the Intranet and open the HTML page named StudentList.html in the StudentList workspace.
  • Task 2 - You will learn to write JavaScript code to sort, reverse, and search the single-dimensional array. You will also write code to convert and join the elements of the single-dimensional array to strings.

Learning Outcomes

After completing this exercise, you will be able to:

  • Sort, reverse, and search single-dimensional arrays
  • Convert and join the elements of single-dimensional arrays to strings

Comprehensive Learning

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