Lesson 3 of 40
Lesson Progress: 0%
Code Example
const numbers = [1, 2, 3];
numbers.push(4);
console.log(numbers);
// [1, 2, 3, 4]Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
push() as a special tool that lets you add something brand new to the very end of your list.Code Example
const pets = ["dog", "cat", "fish"];
pets.pop();
console.log(pets);
// ["dog", "cat"]Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
pop() tool is a quick way to grab the very last item off your list and take it away.Code Example
const fruits = ["apple", "banana", "orange"];
fruits.shift();
console.log(fruits);
// ["banana", "orange"]Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
shift() tool is a special command used to remove the very first item from your list.Code Example
const numbers = [2, 3, 4];
numbers.unshift(1);
console.log(numbers);
// [1, 2, 3, 4]Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
unshift() tool is a special command that lets you add a new item to the very front of your list.Code Example
const colors = ["red", "green", "blue"];
console.log(colors.includes("green"));
// trueInstructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
includes() tool lets you ask the computer if a specific item is hiding inside your list.true if it finds the item, or false if the item isn't there.Code Example
const pets = ["dog", "cat", "fish"];
console.log(pets.indexOf("cat"));
// 1Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
indexOf() tool helps you find the "spot number" where a specific item is sitting in your list.0, so the first item is 0 and the second item is 1.Code Example
const letters = ["a", "b", "c", "d"];
const part = letters.slice(1, 3);
console.log(part);
// ["b", "c"]
const numbers = [10, 20, 30, 40, 50];
const part = numbers.slice(2, 4);
console.log(part);
// [30, 40]Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
slice() tool lets you copy a specific section of your list to create a brand new, smaller list.0, a start number of 1 actually begins the cut at the second item.Code Example
const words = ["Hello", "world"];
console.log(words.join(" "));
// "Hello world"
const letters = ["J", "S", "Fun"];
console.log(letters.join("-"));
// "J-S-Fun"Instructions
▼ ← Click the triangle to hide or reveal instructions.JavaScript Code Editor
Task Incomplete
Editor Input:
Editor Output:
slice() tool lets you copy a specific section of your list to create a brand new, smaller list.0, a start number of 1 actually begins the cut at the second item.