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 1

Solution: Implementing stacks and queues 1 - JavaScript Tutorial

From the course: JavaScript: Arrays

Solution: Implementing stacks and queues 1

(light upbeat music) - [Instructor] Welcome back. In this particular challenge, we've been given an array of scores, and we need to add a score of 7 to the end of this existing scores array. So for this particular challenge, we're going to reach for a very common array method that you're going to find yourself using time and time again. And that is the array method push. So the first thing that we'll need to do is reference our array, scores, and then push, and then you're going to pass the value that you need added to the end of the array. So, in this case, that's 7. Now, in order to check our solution after we've added 7 to the array, let's then return it, scores, and check. All right, let's go ahead and test that. And awesome. You can see that your scores array is now 10, 9, 8, 7, exactly as it should be. Great work.

Contents