Coding task · JavaScript and TypeScript course · Module 2: Functions, Arrays and Objects

Working with Arrays

push() adds an element to the end of an array, shift() removes the first element and returns it, and length gives the number of elements.

Task

Create an array species with the species 'T-Rex', 'Velociraptor' and 'Triceratops'. Add 'Stegosaurus' to the end with push(), remove the first element with shift() and store it in a constant called removed. Display the species array and its length in the console.