Hello, in this JavaScript video, I am going to show you the while loop. So I've got a for loop right here. If this seems a bit alien to you, I would recommend going and checking out the following video. Once you've done that, feel free to pop them back. Okay, so got these for loop eyes have printed that this is incremented by two every single time or call stop with something called a while loop. Let me show you how one works.
Pretty similar. A couple of differences. And enough all those three main parts, there's the setup, the initialization, the condition, the sort of end iteration statement, whereas in a one on one part, and that's the condition itself only for completeness. And you might be thinking, Okay, so how did you get the setup? Any setup needs to occur before. So our code is for j equals zero and we'll send you soon Like this, and any incrementation needs to actually occur with in the within the actual loop itself, it could be at the end of the loop or it could be before so for the statements, that's totally up to you just copy this line.
So this is this is to the show, Jay said This is delicious. Save that need to change this to refresh so we get our zero to 100 and then j zero to 100. Okay, where would you use a while loop over a 40. Okay, so this variable right here that we're using, if this is already been created, and you're just going to use in the wallet, that's a good scenario to use the wallet where you're not actually specifically creating This variable purely for the loop itself, then a wallet is good for it. Whereas if you just want to run a piece of code several times, time and time 10 times doesn't really matter how many times, but you don't actually have this sort of iterator variable already set up and you need to create a new one, then a for loop is the way to go.
That's it for the while loop. Thanks for watching, and I look forward to seeing you in the next video.