Hang with the other loops
There're quite a few different types of loops but I hope you get the gist of them. In this lecture we will explore some more loop types. This is it for us - this is our last content lecture in LEVEL 1 hope to see you in our dedicated animation course of LEVEL 2.
Video Transcript
00:00Whooee! I've been through a lot. You can see how if you've been watching throughout the hours, the window there, how it's getting dark light, dark light, dark light, because it took us weeks to create this course.
00:11I think it's, I hope you got a lot out of it and I'm grateful that you trusted me enough to watch all these and get all the way to this point.
00:19So I want to personally congratulate you and thank you for taking this course.
00:24There's a few more things we're going to talk about, which is loops, a few other variations of loops.
00:29Let's jump right in there and we'll see you in our next title, hopefully our advanced and middle, intermediate animation courses.
00:36Really short lecture. Let's see how to do do while. The difference between do while and while, and I'm just going to save this while.
00:45While, not child, while, and I'm just going to comment it out.
00:51And I'm going to go ahead here and just copy everything here because we're going to use the same exact mythology.
00:58The only difference between do while and while is that do while executes our loop once at least no matter what.
01:04You know what? I'm not going to create this whole complexity because it really is too complicated.
01:09So I'm going to go ahead here and just get rid of some of the stuff here.
01:12I'm just going to set this to zero always.
01:16Now when we create a while, the while doesn't run it if our eye is bigger.
01:21If our eye was already bigger, this will never happen at all.
01:25But if we want our code to happen at least once, no matter what, we instead of that, we start with the command do.
01:31And basically saying is we're just saying just do this. And then we set our while underneath.
01:37So the do while basically will happen once no matter what, because the condition only happens after we did it once.
01:44So after we did it once, if our condition is still mad, then we're going to go back up there to do it again.
01:49OK, so this is do while if we run it just for a second here, we'll see that our eye growing there.
01:55I'm not going to do the whole dimensional thing because there's just no need to do that.
01:58And I want to run over to the next topic really, really quickly.
02:02And to do that, I'm going to create here a four in.
02:06Now the four in works this way. I'm just going to create here an array or even in.
02:10Yeah, let's create here an array and I'm going to put here a few items.
02:14Cat cat dog goat. All right, let's just do a really simple four in.
02:25Now the four in is basically it works this way. You write your four var item in a and let's sit.
02:36Basically what will happen if I don't go to my console and I log it out, we're going to and I log out the item.
02:42We're going to get basically the index of that item, but it doesn't have to be an index.
02:47Let me show it to you with an index first and we'll run it really quickly.
02:51And we'll see in our output that we're getting our indexes from zero one two is basically fetching back our keys.
02:57Now the same rule applies if it wasn't an array and we were doing this on an object.
03:02So I'm just going to quickly create here a really quick object.
03:06I'm going to call this cat says hello dog barks and goat man.
03:20All right, doesn't have to be too sophisticated. And if I instead of this loop through our oh,
03:26instead of looping through our a we're going to get the keys cat dog goat,
03:30whatever other keys we would have inside of our object.
03:34We would fetch our objects properties by looping through them.
03:38Now beyond that we could also very easily if we wanted to,
03:41we could have fetched the actual value and by all we have to do is just approach that.
03:46Oh, oh, and just wrap it around in that bracket and then we would get our item back.
03:54So we'd get that say hello barks.
03:56So I could have here basically item says literally,
04:04I'm just going to paint out a conversation out of just this really simple construct.
04:10If I do that and I click on refresh, we're going to see a cat says say hello.
04:13A dog says barks. A goat says man.
04:17All right. So obviously we ran through this very quickly.
04:21I really hope to see you in our advanced courses.
04:24If our advanced animation courses or other advanced courses were
04:28we're going to practice a lot more loops as loops are very critical,
04:31important elements in programming deliberately.
04:33I left it as the last thing one is because it's a bit more complicated
04:37and two because I don't want you to go to it as your default always.
04:41I want you to focus on objects. I want you to focus on arrays.
04:44I want you to focus on trying to make things simple and approaching our functions
04:49and approaching loops and approaching if conditions when you have to,
04:53not as your default. So I hopefully throughout the last seven hours,
04:57I ingrained into all those other values.
05:00And now that you're aware of all these last really critical things in programming,
05:04you'll be a really wonderful programmer. And that's it.
05:07Hope to see you in the intermediate level animation course where our main focus
05:11is going to be animation and not the programming aspect of it necessarily,
05:16which was this title. See you in the next title.
05:19Thanks again for watching.
