This course has been updated! We now recommend you take the Deep JavaScript Foundations, v3 course.
Transcript from the "Exercise 1" Lesson
[00:00:00]
>> [MUSIC]
[00:00:04]
>> Kyle Simpson: So I will orient you to the exercise, what you wanna do, and again as a reminder both for you here in person as well as for you listening in online. If you only have one copy of that exercises folder, before you start modifying things, I recommend just making a separate copy of your exercises folder.
[00:00:21] That way at some later date, you can go back to a pristine copy of these exercises and try your hand at them. But, we're gonna open up, I got to go to day one. We're going to go the exercises folder. Go to Ex 1. You can open up the readme file and the JS file.
[00:00:36] All right. [COUGH] The readme is gonna explain what you need to do, but also you're gonna come over here to your browser and open up ex1.html which is gonna load your ex1.js. And you're immediately gonna get an error on the very first line of your program. That's on purpose.
[00:00:58] Okay? So, what this says is, it wants you to fix the code so that our program will correctly print out the full alphabet A through Z. That's what the program's designed to do. Right now, our error's out. We've got to fix those errors. This is asking you to take what you've learned about scoping, about hoisting, about IIFEs and all that other stuff.
[00:01:17] Put all that stuff together into a way to solve the problem. Now, I have constrained your ability to solve this problem. You are not allowed to just put console.log a, console.log b in a program to solve it. So I've constrained your solution. You cannot have any global variables at all.
[00:01:34] If you look at the file, you'll see everything's global. So first thing you're gonna have to solve is that you have to stop having any global variables at all. The second thing is that you cannot delete or combine any of the existing function declarations. You have to leave the function declarations or whatever as they are.
[00:01:50] You can't delete or combine them. You cannot create any new functions, except there's an exception, that you can create IIFEs. And that's a big hint, cuz you're gonna need to create some IIFEs. And you cannot rearrange the order of any of the declarations. You have to use what you know about the way hoisting works to solve your problems.
[00:02:08] The things that you can explicitly do is you can declare extra variable as long as their not global. You can modify a function declaration and turn it from a declaration into an expression. or from an expression into a declaration, and you'll probably need to do that. You can add or remove various statements or expressions, like the returns, or IIFEs, or parameters.
[00:02:28] And the explicit answer here is you wanna search for making the fewest changes possible. This does not call for you to change every line of this entire program. To solve the problem. So go through it one at a time. Try to constrain yourself to these rules, and see if you can get it to print out, a through z.
[00:02:49] I will walk you through an answer to this in a few minutes right before we take our lunch break.