This course has been updated! We now recommend you take the JavaScript: The Recent Parts course.

Check out a free preview of the full ES6: The Right Parts course:
The "Exercise 2" Lesson is part of the full, ES6: The Right Parts course featured in this preview video. Here's what you'd learn in this lesson:

In this exercise, you will modify the code in the ex2.js file and use the gather and spread operators manipulate the two arrays in the bar function. This way the foo function returns a value that makes the console.log statement at the bottom true.

Get Unlimited Access Now

Transcript from the "Exercise 2" Lesson

>> [MUSIC]

>> Kyle Simpson: I think that's good on our gather and spread. So let's open up exercise two. And this is we will finish exercise two and then take our lunch break. Okay so go ahead and open it up and I'll orient you to exercise two and then give you. Will take like five minutes on exercise two, four minutes, it's a short exercise, okay?

[00:00:33] Same kind of thing that I was just talking about before the kinds of tricks that we can play with spreads, and gathers, and with parameters. The spirit of this exercise is that when I call the bar function, which is giving me back whatever comes back from foo, that's gonna give me an array that, if I join those together, comes to this string.

[00:00:53] In other words, I'm expecting an array back with the values 2, 8, 10 and 12 in it. And the starting values that I have to play with, are these two arrays. So in some way shape or form. I want to transport those values into foo, and in some way shape or form, I want to declare foo and return something from foo that ends up resulting in an array that has 2, 8, 10, and 12 in it.

>> Kyle Simpson: So using the same sort of stuff with gathers and spreads that we just talked about. See if you can declare that code.