We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Arrays

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']

Assignment

Textio keeps a record of messages that have been successfully sent. Your task is to manage this message history using an array.