This course has been updated! We now recommend you take the Deep JavaScript Foundations, v3 course.

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

For this exercise, you will be using the files in the day1/ex5 folder. Look at the file for exercise instructions. In the interest of time, Kyle gives this exercise to the audience as a "homework" assignment.

Get Unlimited Access Now

Transcript from the "Exercise 5" Lesson

>> [MUSIC]

>> Kyle Simpson: Unfortunately, I'm gonna have to assign you yet another piece. I'd hoped that we could get a chance to go through this. There is a this exercise 5, this a brand new one that I just created, so you guys are the first ones to see this. But I really encourage you to spend some time tonight playing with it, cuz it's actually kinda fun.

[00:00:20] What the task is, it's a fake AJAX load but it requires you to load up three separate files in parallel. You're gonna try to get the contents of those files at the same time, so you want to do it in parallel but it wants to make sure that you print them out in the proper order.

[00:00:40] And that's a deceptively simple sounding task, that's actually a little bit complex to figure out. I've implemented it using callbacks, and you can see how difficult it is to manage the state with nested callbacks. Then the challenge for you is using whatever promises or generators syntax you like, whatever library, I've shown you how to do it with a sequence, and I've also shown you how to do it, there's files in there to do it with a sequence and also with native Promises.

[00:01:07] But whichever format you want, I want you to try to solve that task. How could I load up three separate things but make sure they print in the proper order because that is a real world asynchronous task that we face in our code. I wish we have time to kind of talk through it.

[00:01:22] If you guys have questions about it, please feel free to email.
>> Speaker 1: It could maybe take ten minutes tomorrow morning.
>> Kyle Simpson: Yeah, we'll probably go over the exercise, if you guys get a chance tonight, we'll probably go over the exercise. That's a good idea. [COUGH] Speaking of tomorrow, tomorrow is going to look somewhat different than today in terms of the style of the way the class goes.

[00:01:41] Just to prepare you guys as you're packing up, the style for tomorrow is going to be a lot more code and a lot less lecture. That may or may not be what you're hoping for but there will be a lot less slides, a lot less of me standing for long periods of time and talking and we're going to do a lot more tinkering at the code.

[00:02:01] You're going to write real world node code, and the goal is to take what we learned today as a foundation of confidence so that we can write code in our node JS processes without worrying about how these mechanisms work. We'll revisit asynchronicity and we'll revisit a whole bunch of these other things as we deal with.

[00:02:21] I appreciate everybody's time today and all your great questions and participation. I look forward to tomorrow, to the second day. If you have any questions, let me know but I appreciate it very much.