From the course: JavaScript: Arrays
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Implementing stacks and queues 2 - JavaScript Tutorial
From the course: JavaScript: Arrays
Solution: Implementing stacks and queues 2
(bright music) - [Instructor] In this challenge, we're given an array of months, and we need to add January to the beginning of that array. So for this particular challenge, we're going to reach for the array method, unshift. So just as we did in the previous one with push, we're going to start with our months array, and we're going to unshift. So use that method, and then we're going to pass the string January, oops. And make sure that we spell that correctly. And as I've said many, many times, make sure that your casing matches, because we're going to need to then return this, and check it to make sure that it's the correct solution. So return months. All right, and then let's go ahead and test it. And awesome, we got the correct answer. You can see January has been added to the beginning of the months array. Great job.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.