

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Arrays
incomplete
2: Array Length
incomplete
3: Array Spread
incomplete
4: Includes
incomplete
5: For...of Loops
incomplete
6: Slicing Arrays
incomplete
7: const Arrays
incomplete
8: Destructure
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
JavaScript's arrays are similar to Python's lists.
One important thing about JavaScript arrays is that items in an array are not required to be of the same type... Remember, JavaScript is about as loosy-goosy as programming languages get...
const numbers = [1, 2, 3, 4, 5];
const strings = ["banana", "apple", "pear"];
const miscellaneous = [true, 7, "adamantium"];
You can index into an array using square brackets []:
const strings = ["banana", "apple", "pear"];
console.log(strings[0]);
// Prints: 'banana'
And you can .push() new items onto the end of an array:
const drinks = [];
drinks.push("lemonade");
console.log(drinks);
// Prints: ['lemonade']
drinks.push("root beer");
console.log(drinks);
// Prints: ['lemonade', 'root beer']
Textio keeps a record of messages that have been successfully sent. Your task is to manage this message history using an array.