JavaScript 2 - Arrays, Functions

Projected Time

About 2 hours

Prerequisites

Motivation

JavaScript is used on the frontend of almost every website. It’s also a widely-used scripting language that be used on the backend as well. The JavaScript lessons set a solid foundation in JavaScript basics so we can use the language in more robust ways in later lessons.

The data structures and syntax introduced in this course are fundamental for creating applications at all scales. They are tools that are used in any technology company and are often part of assignments for technical phone screens or on-site interviews. They ask questions about these concepts in interviews at Lumosity, Google, and Facebook, to name a few.

Objectives

Participants will be able to:

Supplemental Materials

JavaScript Arrays

General JavaScript

Lesson

JavaScript II - Arrays, Functions (video walkthrough of slides 1)

JavaScript II - Arrays, Functions (video walkthrough of slides 2)

JavaScript II - Arrays, Functions (slides)

JavaScript II - Arrays, Functions (difference between var/const/let and scopes explained video)

JavaScript II - Arrays, Functions (difference between var/const/let additional reading)

Things to Remember

Independent Practice

Techtonica staff will assign pair partners.

  1. In REPL.it, create a function called printCuteAnimals that expects an array to be passed in as an argument. You can name the function parameter whatever you like. When you pass the array to the function, it should contain strings, and the strings should be types of animals you think are cute.

Your function should:

  1. First print the entire array and its length.
  2. Print the array after you have called the .pop() method on it.
  3. Concatenate another array of animal names onto the exisitng array. Feel free to look up how to do this using Google!
  4. Print the array again and its new length.
  5. Return the array.

Challenge

Using MDN’s JavaScript documentation, identify 1 - 3 array methods (look on the left column) that you can incorporate into your function, and see if you can.

Check for Understanding

Find a partner and answer these questions: