Hello! I’m Erica Gomez, and I work as a software development manager at Amazon. I love my job because it allows me to guide junior engineers, helping them advance in their careers and discover exciting opportunities. My role also involves strategic thinking, which is a refreshing challenge beyond just focusing on immediate tasks.
Think about how you organize your day, brainstorm project ideas, or pick songs for a party. You likely jot these down in a list. Lists are fantastic for keeping things organized by gathering all relevant information in one place. This concept is similar when we write programs that need to manage multiple related pieces of information.
While variables are great for storing a single piece of information, things can get tricky as you gather more data. Imagine trying to track everyone’s names in a class or an entire school. Creating hundreds or thousands of individual variables would be impractical, especially if you don’t know the exact number of items you need to track beforehand.
In JavaScript, we can efficiently manage such information using arrays. An array is an ordered collection of items, much like a row of numbered boxes, where each box holds one item. Arrays can store various types of data, including numbers, strings, and even other arrays.
Let’s explore how you can use an array to keep track of names in a group. In JavaScript, an array of strings might look like this: ["name1", "name2", "name3"]
. Notice that each item in the array is separated by a comma, and the entire array is enclosed in brackets. Just as you can assign a number or a string to a variable, you can also assign an array to a variable for future use.
Whenever you create a new array, it’s essential to assign it to a variable so you can reference it later. Your array can be as long as you need; you can adjust its length using the arrow keys on the side of the block.
To access a specific item from your array, write the name of the array followed by the index of the item you want to access. For instance, if you want the item in the array “names” at index 2, you would write it like this: names[2]
. It’s important to note that in programming, we usually start counting at 0. This means the item at index 0 is the first item in the array, and the item at index 2 is actually the third item.
When your program runs, the computer will look up the current value at the specified index of the array, just as it looks up the current value of a variable. Arrays are a powerful tool for writing programs that handle large amounts of data, enabling us to process extensive information, especially when the exact amount of data to be stored is unknown in advance.
Now, let’s dive in and try using arrays!
In this activity, you’ll be given a list of tasks that require you to find specific items within an array. Create an array of your favorite songs, and then write JavaScript code to access and print the song at a given index. This will help you practice using indices to retrieve data from arrays.
Write a JavaScript program that starts with an array of numbers. Your task is to perform various operations: add a number to the end, remove the first number, and insert a new number at the second position. This will help you understand how to manipulate arrays using methods like push()
, shift()
, and splice()
.
Form a group and brainstorm an application idea that heavily relies on arrays. Develop a simple prototype using JavaScript, focusing on how arrays can be used to manage data efficiently. Present your project to the class, explaining how arrays are utilized within your application.
Create a visual representation of an array using a drawing tool or software. Label each index and item clearly. This exercise will help you visualize how arrays are structured and how data is organized within them, reinforcing your understanding of array indices.
Participate in an online coding quiz focused on arrays. The quiz will present you with various scenarios and problems that require you to write code involving arrays. This will test your knowledge and help you identify areas where you might need further practice.
Sure! Here’s a sanitized version of the transcript:
—
Hi, my name is Erica Gomez, and I’m a software development manager at Amazon. I really enjoy my role because I get to mentor junior engineers, helping them grow in their careers and find the right opportunities. I also have to think more strategically rather than just tactically.
When you’re planning your day, brainstorming ideas for a project, or choosing songs for a party, how do you keep track of all your activities, ideas, or songs? You probably write them down in a list. Lists help us stay organized by ordering all the relevant pieces of information in one place. The same principle applies when we write programs that include many related pieces of information.
Variables are useful for keeping track of a single piece of information, but as we collect more data, keeping the variables organized can become complicated. For example, if you wanted to keep track of everyone’s names in a class or an entire school, it would be impractical to create hundreds or thousands of individual variables, especially if you don’t know how many items need to be tracked ahead of time.
In JavaScript, we can manage all this information using an array. An array is an ordered collection of items, which you can think of as a row of numbered boxes. Each box can hold one item. Arrays can contain all types of data—numbers, strings, and even other arrays.
Let’s see how you could use an array to keep track of the names of people in a group. In JavaScript, an array of strings looks like this: [“name1”, “name2”, “name3”]. Notice that all the items in the array are separated by commas, and the entire array is enclosed in brackets. Just like you can assign a number or a string to a variable, you can also assign an array to a variable for later use.
Every time you create a new array, you’ll want to assign it to a variable so you can reference it later. Your array can be as long as you want; just use the arrow keys on the side of the block to adjust its length.
To access an individual item from your array, write out the name of the array followed by the index of the item you want to access. For example, if you want the item in the array “names” at index 2, you would write it like this. The official term for index 2 is “index.” You might have noticed that the first index in the array is 0. In programming, we usually start counting at 0, which means that the item at index 0 is the first item in the array, and the item at index 2 is actually the third item.
When your program runs, the computer will look up the current value at the specified index of the array, just like it looks up the current value of a variable. Arrays are a powerful way to write programs that handle large amounts of data, allowing us to process lots of information, especially when we don’t know in advance how much information needs to be stored.
Let’s try them out!
—
This version maintains the original content while ensuring clarity and professionalism.
Arrays – Data structures that store multiple values in a single variable, often used to organize and manipulate data efficiently in programming. – In our computer science class, we learned how to use arrays to store and access a list of student grades efficiently.
JavaScript – A high-level, dynamic programming language commonly used to create interactive effects within web browsers. – The professor demonstrated how JavaScript can be used to enhance the functionality of a website by adding dynamic content.
Variable – A symbolic name associated with a value and whose associated value may be changed, used in programming to store data that can be referenced and manipulated. – In the coding exercise, we declared a variable to store the user’s input and then used it to display a personalized message.
Data – Information processed or stored by a computer, which can be in the form of text, numbers, or media. – The data collected from the survey was analyzed using a statistical software program to identify trends.
Information – Processed data that is meaningful and useful for decision-making or analysis in computing contexts. – The database management system helps organize information so that it can be retrieved quickly and efficiently.
Names – Identifiers used in programming to label variables, functions, classes, and other entities, allowing them to be referenced and manipulated. – Choosing descriptive names for functions and variables is crucial for maintaining readable and maintainable code.
Coding – The process of writing instructions for a computer to execute, using a programming language. – During the hackathon, students spent hours coding to develop innovative software solutions.
Program – A set of instructions written in a programming language that a computer can execute to perform a specific task. – The final project for the course required students to write a program that could solve complex mathematical problems.
Manage – To control or organize data, resources, or processes within a computing environment. – The new software tool helps manage large datasets by providing efficient sorting and filtering options.
Items – Individual elements or entries in a data structure, such as an array or list, that can be accessed and manipulated in programming. – The function iterates over all items in the list to calculate the total sum.