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

Check out a free preview of the full Deep JavaScript Foundations course:
The "Challenge 1: Coercion" Lesson is part of the full, Deep JavaScript Foundations course featured in this preview video. Here's what you'd learn in this lesson:

In this challenge, students fix a simple application by checking types and coercion.

Get Unlimited Access Now

Transcript from the "Challenge 1: Coercion" Lesson

>> : Kyle Simpson: Okay and let's talk about our first exercise. If you will open up with me the read-me, as well as the EX1.js and the EX1fixed.js. Actually you don't need to worry about the solution file yet, but at least the read-me and the fixed file. And then in your browser if you would open up with me the fixed HTML version of it.

[00:00:22] So we're gonna demonstrate this little app that I've built. Obviously, it's a very simplified app to log work against a set of projects. We're gonna use this exercise, this application to illustrate all of the things throughout the rest of the workshop. So we're gonna practice it here with our types and coercion.

[00:00:42] Then we're gonna come back to it multiple more times. A total of eight more times that we'll be revisiting it. So the first time here, I want you to get more familiar with the behavior that you're expecting. So if I say this is some work I did, and then I give it some amount of time like I spent 75 minutes on it and I submit.

[00:01:01] It added an entry into my client features projects of 1:15. If I did some more work, but it was only 30 minutes of time, you notice that it's gonna actually sort it in descending order. So I did a really long project and I spent 200 minutes on it, it keeps to the top.

[00:01:20] So it's gonna keep sorting it in descending order. If I add items to my other setup projects like boring debugging and I said, I only spent 20 minutes on that. Then, it's gonna add it to my other project, okay? So it's a very straightforward and simple application, but it's gonna illustrate a lot of the things that we wanna talk about in this workshop.

[00:01:46] So that's the fixed version of it as it currently stands, it doesn't fully work. A lot of the code's already been written but it doesn't fully work, there are several bugs. And I cover in this Readme in detail, exactly what you need to know to look for to fix those bugs, okay?

[00:02:02] So I know your instinct is probably to say, I'm just gonna skip out on reading the Readme. I really strongly recommend. Click around in that demo yourself in the fixed version so you see how it works. Read through the EX1.jscode. This is the code that's provided. It's this 175 lines.

[00:02:18] And then compare that to what you read in the Readme, that will tell you the things you're looking for to fix. It mentions, for example, that you should not need to create any new functions or reorganize significant chunks of code for the exercise. You only need to make a few spot changes and a few lines of code, that's all that necessary, all right?

[00:02:39] So I've given you 15 minutes of which more than half of that is just for you to play around and get used to this, get used to this code base and how it works. The changes shouldn't take more than a few minutes. But we list out, here are the things you need to fix.

[00:02:52] Here are some hints to look out for. Are there strings that should become numbers or vice versa, that sort of thing. And then there is a validation function that you need to fill in, replacing the TODO comment with the items listed here, okay? So that's the subject of the exercise.

[00:03:09] We'll give you 10, 15 minutes to work on that, and then we'll come back and talk through the solution.