02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous Video
Chapter is concluded.Next is Conditions.

Wrapping things up

Chapter 6 is officially over with this lecture. In this lecture, we tie up some loose ends to complete the application we promised in the beginning of the chapter. As we do that, we will practice more "linker" objects. In my perspective, link objects are the most powerful feature in programming that hide inside of them a plethora of complexities that simplify our code. There're a few more concepts we haven't learned yet, deeply. The first is conditions, and the second is loops. Try to go back to the samples every time you learn a new concept as it will shed a lot more light onto them.

Video Transcript

00:00No, intros are really needed. We're wrapping up the chapter and completing our project
00:05So let's jump right into the chapter up in the last chapter
00:08We created that linker and saw how that relationship worked and really in many ways
00:12That's exactly what we're gonna do in the analyze now one thing. I like doing I don't like having my
00:18Variables spread all over so a good thing to do is just in general put your global variables all the way on the top there
00:25that way as
00:26As soon as your application starts, they're initiated
00:29You could see where they're being initiated and I'm going to create another variable and this is going to be our database
00:35So I'm going to just call it DB and I'm just going to create from our DB a new object
00:39And that's it. This is going to be the object that I refer to every time I go inside of my
00:45Analyze function. So now the next step is first of all, I'm just gonna just remember this variable here in the side here
00:52and I'm just gonna fetch my the name of the eye of the user that have that has what that has
00:57That was added in and the next thing is I want to save the date itself as well
01:02So I'm gonna go ahead and just save the value of the of the person that is being dated
01:07Now the next step that I'm gonna do is I'm gonna literally go to my DB and I'm gonna ask my DB
01:14If that name exists already now
01:16The easiest way to do that is literally just to go to my DB and ask it if the name exists
01:22Basically, if there is someone there then something will come back if there's no one there then nothing will come back
01:28If nothing come back nothing comes back
01:31what I want to do is I want to take that item and I want to put inside of it a new array and
01:37This array is an empty array
01:38so this will happen only if there is no one in this if there's no one with that name already inside if
01:45someone with that name is already inside what I want to do next is I want to approach my item which is an array and
01:51I what I really want to do is I want to push into it
01:55the date and
01:57You guessed it the way I do that is using the push function
02:00That is it is a function that exists only for arrays and I could send into it another item and it will push it
02:06To the end of the list. So there you go. So now what I'm gonna do just just to kind of like
02:12Wrap this up and test it out and make sure that it works
02:15Is that what I want to do is I want to approach our if I just find that little let's just look in the HTML
02:20I want to find that paragraph
02:22So I'm gonna go ahead and just copy that paragraph right here and go all the way to the top
02:27Into our analyze function if I find it. Here we go
02:31What I'm gonna do is I'm gonna go into my analyze function
02:34Gonna approach that item and I'm gonna say hey change your text
02:39And I'll just write here maybe the name
02:44Plus has dated these people
02:50These people and I could literally just go ahead here and just add here my name here and I'll just go automatically it's just gonna
02:59Paste it in here and I'll just make sure that it's gonna be to string
03:02Which is another function of the array which will make sure that we take everything here and just convert it into a string
03:08so if I save this and
03:11by the way an even better way is to use the join and
03:16Join as a function that enables me to select what separator I want to have so in this case
03:20I could say I want to have us a comma a comma and a space making sure that in between each item
03:26There'll be a comma and a space
03:28So if I save this run my app just one time and I'll just click here refresh or even better
03:33I'll make sure by throwing in our item inside and I'll just type here
03:40Oh, you know what? Even before we do this. I want to tell you also one more thing
03:42So remember when we were talking about the change and I said I'm not gonna talk about it
03:46So now they're already so deep inside actually really want to talk about it
03:50I want to change it from change to be key up and
03:52key up will be every time that my keyboard goes up it's gonna update and call this function and
03:58Every time I my keyboard goes up when I'm inside of that T name that way as soon as I type something
04:03It should enable it as soon as we go
04:05So it's gonna be a lot more smooth that way when we click on the tab
04:08It should take us to the right place already once we do that
04:11So let me just position ourselves again in our in our ear analyze function
04:16and I'm gonna go back into that element into our browser really fresh and
04:21I'm gonna go ahead right away and I'll just type here Ben. I'm gonna tab
04:25it's gonna take me right to the right place and let's add dated Mary and
04:28I am going to analyze and first of all, I have your little error
04:32It's telling me that the DB name is undefined. Alright, so let's see why
04:37What what is wrong in our code?
04:40So we said here if DB name
04:43Then we want to do this
04:44But this is exactly the opposite because really what we want to have is only if it doesn't exist
04:49Then we want to reset it. So that was a huge mistake
04:52The way we saw this is I could say I just add the command not and it's literally just the
04:59command line and when I split the command line before the value it would take whatever the value is and flip it around so
05:25If there is a value here, it's gonna flip it around turn it into no value
05:28If there's no value, it's gonna flip it around into value. Basically, it's gonna turn it from whatever it is to false or true
05:35So in this case, that's that is exactly what I needed to solve that problem there because we were basically they were right
05:41We never had the DB created
05:45So let's go ahead we're gonna do this just one more time and hopefully now it's gonna work
05:51So if I type your Ben, I'm gonna click on
05:53Space so whatever marry and I'm gonna just click on to analyze
05:58So Ben has dated these people marry and I'm gonna go ahead and I'm gonna add here. Let's say Sam
06:05analyze
06:07Can't even think of names
06:13Sue Sue, let's say we let's say I did it. Soo. Let's say I did it or n
06:19Let's say I dated
06:24Melinda why not?
06:27There you go in the end. These items are updating now. I have a task for you. This is it
06:33I'm done with this chapter. You're gonna have to do it on your own if you really want this to work
06:38It would be amazing to see if you could create a deeper
06:42Deeper much more complicated output here because we could have here a lot more than just been we could have your oh, so
06:48We could go later to Mary and say hey Mary also dated Melinda. So Melinda has dated oh, so
06:55It would be wonderful if we could have next to Mary just like a side note that says how many people she dated
07:00Alright, so that is gonna be your task and remember that's your homework and you'll figure out if you could do it on your
07:05Own now or maybe you'll have to go back to it after we finish up the next chapter
07:09which will give you a little bit more ammunition and
07:13maybe if we do a live event you might see this in our live event where we solve this conundrum that we've just
07:19Presented in front of you or if you go into the comment section
07:22Then I'll be more than happy to interact with you live and figure it out together. Alright, so that's it
07:26We're done with chapter the chapter
07:28Chapter 6 is over complete and I encourage you to make even cooler analyzations
07:34So we'll see you in the next chapter. Thanks again

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!