1
00:00:00,440 --> 00:00:01,340
Welcome back.

2
00:00:01,730 --> 00:00:08,690
Before we go to the for Loop, I wanted to show you another application of the wire loop because it

3
00:00:08,690 --> 00:00:12,860
will make it a little more clear what the difference is and when to use what.

4
00:00:13,160 --> 00:00:19,700
So, for example, the for loop is really there to iterate through rangers' arrays and so forth.

5
00:00:19,710 --> 00:00:22,540
And we will see what that means in the next video.

6
00:00:22,880 --> 00:00:30,050
But before we do so, we will have to look at while loops which are great to execute a block of code

7
00:00:30,050 --> 00:00:33,370
repeatedly as long as a condition is met, as we saw earlier.

8
00:00:33,830 --> 00:00:39,230
So let's have an example where we don't look at numbers because so far we only looked at numbers.

9
00:00:39,440 --> 00:00:44,330
We said, OK, var X, as long as X is, why, then do something.

10
00:00:44,720 --> 00:00:52,700
But now let's say we have the situation where we have a variable called felt temperature and that one

11
00:00:52,760 --> 00:00:53,470
will be cold.

12
00:00:53,480 --> 00:00:56,240
So let's say we are in the room and it feels like it's cold.

13
00:00:56,930 --> 00:01:01,040
So we don't know directly what temperature it is in terms of degrees.

14
00:01:01,040 --> 00:01:03,260
Right, in terms of degrees Celsius.

15
00:01:03,680 --> 00:01:09,870
So we have also a value called room temperature, which actually is that value.

16
00:01:09,890 --> 00:01:11,480
So let's say 10 degrees.

17
00:01:12,590 --> 00:01:13,100
And.

18
00:01:14,260 --> 00:01:21,340
Now we will run a wild loop, which will increase the temperature, the room temperature, by one degree

19
00:01:21,820 --> 00:01:27,400
until it's warm enough so that temperature is not cold anymore.

20
00:01:28,180 --> 00:01:33,330
So here we are just going to say, as long as fildes temp is cold.

21
00:01:33,970 --> 00:01:39,490
Please run this while loop, which will, as I said, increase the room temperature.

22
00:01:42,570 --> 00:01:48,420
So now, of course, we still need a situation where this condition is not met any more, so we need

23
00:01:48,420 --> 00:01:57,780
to create this situation so we can check if the room temperature is greater or equal 20.

24
00:01:59,220 --> 00:02:07,370
Then set the felt temperature too comfy, so too comfortable, so it's not going to be cold anymore

25
00:02:07,770 --> 00:02:11,280
and also print something onto the console, parental and.

26
00:02:12,420 --> 00:02:15,010
It's comfy now.

27
00:02:15,540 --> 00:02:17,460
So now if we execute this.

28
00:02:19,130 --> 00:02:21,180
It will just print its coffee now.

29
00:02:22,040 --> 00:02:23,990
Why is that what happened in this whole thing?

30
00:02:24,380 --> 00:02:31,100
Well, we set the temperature too cold because when it's 10 degrees Celsius, then it's pretty cold

31
00:02:31,100 --> 00:02:33,950
and we don't want to be in the room when it's that cold.

32
00:02:34,160 --> 00:02:36,050
Wanted to be 20 degrees Celsius.

33
00:02:37,530 --> 00:02:40,140
Which is 60 degrees Fahrenheit.

34
00:02:40,770 --> 00:02:45,950
All right, so what you say is as long as it's cold, please turn up the heat.

35
00:02:46,260 --> 00:02:48,540
So increase the room temperature by one.

36
00:02:49,490 --> 00:02:54,110
And as soon as the room temperature hits 20 degrees.

37
00:02:55,500 --> 00:02:59,010
Then said the Feld's temperature too comfy.

38
00:02:59,040 --> 00:03:01,780
So now in the room, we feel like, all right is comfy.

39
00:03:01,800 --> 00:03:02,700
It's a good temperature.

40
00:03:03,150 --> 00:03:08,790
We can maybe even get rid of our jacket and then we can print.

41
00:03:09,000 --> 00:03:09,870
It's comfy now.

42
00:03:10,730 --> 00:03:16,580
And our while loop will stop, so at that point, our while loop will not increase the room temperature

43
00:03:16,580 --> 00:03:22,460
anymore and it will jump out of this whole loop and execute whatever comes afterwards.

44
00:03:24,030 --> 00:03:29,280
So this is just another application where you see that it doesn't have to be an integer that we're checking

45
00:03:29,280 --> 00:03:33,770
here, it can be whatever condition that has to be met.

46
00:03:34,050 --> 00:03:40,290
And as soon as this condition is not met anymore, the wire loop will stop executing its block here,

47
00:03:40,290 --> 00:03:40,920
its body.

48
00:03:41,160 --> 00:03:41,880
It's called Block.

