This course has been updated! We now recommend you take the Deep JavaScript Foundations, v3 course.
Transcript from the "Exercise 2" Lesson
[00:00:00]
>> [MUSIC]
[00:00:04]
>> Kyle Simpson: All right, exercise two. I've listed it 20 minutes. It shouldn't take you more than five. Cuz really, you're gonna write like eight lines of code. But as they say, they important thing is which eight lines of code do we write? So, let's open up exercise two. You can open up the read-me and the JS file.
[00:00:27] I'm going to open up, in a browser, the fixed version of the code because I want you to see what it's supposed to do. Well actually it doesn't matter. The fixed version is not fixed. Let's just look at exercise two. I'll open up the HTML file. It's a simple note taker app.
[00:00:46] We have built in. You know you can click on the notes and highlight them. You can click out. You can add stuff and you have a little help dialog that tells you what to do. So it's a simple little note taker. You're not gonna add any functionality to this app, but what you are going to do is use the classic module pattern to organize the code better.
[00:01:05] So, if we look at EX2.JS, it's a whole bunch of global functions with no organization whatsoever. And what I want you to do, is using what I just taught you about the module pattern, go back and turn this into a well formed Module. And I explained how to do that.
[00:01:21] You'll have two methods on your public API, one will be called init, one will be for loading and data, you'll create yourself a little module API and then modify the code to do that. So, again, you're literally writing like less than 15 lines of code. If you find yourself doing lots and lots of coding, you're doing it the hard way.
[00:01:43] It's very simple but go back to your slides where I discussed the classic module pattern, the characteristics of a wrapper function, and a return value and all that. That should be more than enough to get you going. I'll give you guys maybe eight or ten minutes, and then we'll come back and I'll talk you through a solution.