WEBVTT 00:00:06.930 --> 00:00:11.910 In this video we going to get introduced to BHB conditional statements. 00:00:12.780 --> 00:00:20.310 So just tell we get to write a piece of code where we are going to be checking whether a condition is 00:00:20.730 --> 00:00:27.060 true and based on that we can print something on the web page. 00:00:27.710 --> 00:00:32.490 So it create a variable we're going to call it believe in your dream 00:00:37.390 --> 00:00:39.280 and are going to set it to true. 00:00:39.690 --> 00:00:41.100 It's a billion. 00:00:41.490 --> 00:00:42.550 All right. 00:00:42.700 --> 00:00:46.830 And now we're going to check if OK 00:00:50.130 --> 00:00:53.820 if you believe in your dream. 00:00:54.000 --> 00:00:56.430 So the syntax is similar to Javascript. 00:00:56.520 --> 00:00:59.710 So we put the condition inside parentheses right. 00:00:59.820 --> 00:01:04.460 So the keyword if and after that are we. 00:01:04.500 --> 00:01:08.760 If it's true we are going to echo something with our screen. 00:01:09.380 --> 00:01:09.870 OK. 00:01:10.110 --> 00:01:17.610 So unlike javascript do you you don't have to use curly brackets but it's better to use Curl-Burke is 00:01:17.610 --> 00:01:21.380 for readability reasons. 00:01:21.380 --> 00:01:21.730 OK 00:01:23.320 --> 00:01:25.840 . 00:01:28.830 --> 00:01:33.760 And if the condition is not true then we're going to use. 00:01:33.760 --> 00:01:35.820 Else OK. 00:01:36.090 --> 00:01:37.950 And we're going to echo something else 00:01:37.970 --> 00:01:43.680 . 00:01:48.810 --> 00:01:49.080 OK 00:01:53.760 --> 00:01:58.650 so if it's true we can take for example a paragraph 00:02:01.620 --> 00:02:03.510 . 00:02:05.400 --> 00:02:10.410 You will be successful. 00:02:13.150 --> 00:02:13.850 OK. 00:02:13.960 --> 00:02:20.720 Otherwise we're going to echo believe in your 00:02:25.070 --> 00:02:28.110 in your dream to be successful 00:02:32.820 --> 00:02:33.300 in life. 00:02:33.450 --> 00:02:34.780 OK. 00:02:35.040 --> 00:02:42.030 All right so now let's save and refresh the page where you can see our resolve there because the condition 00:02:42.030 --> 00:02:48.620 is true if we said that's false then if we're fresh we can see the other message. 00:02:48.680 --> 00:02:49.550 Us. 00:02:50.250 --> 00:02:51.410 All right. 00:02:52.060 --> 00:03:01.920 OK so now we going to look at another way of setting a certain variable. 00:03:02.150 --> 00:03:07.270 Ok two different values depending on the condition. 00:03:07.500 --> 00:03:16.260 OK so rather than than we could we could use if condition then set the variable to a certain value else 00:03:16.260 --> 00:03:16.340 . 00:03:16.350 --> 00:03:18.230 So the variable to another value. 00:03:18.480 --> 00:03:20.730 But we're going to try something else. 00:03:20.730 --> 00:03:24.180 So our variable is going to be x. 00:03:24.490 --> 00:03:25.600 OK. 00:03:26.850 --> 00:03:33.210 And we are just going to set it straight away like this. 00:03:33.240 --> 00:03:40.670 So we're going to say variable x equals OK and which reimburses we're going to have our condition. 00:03:40.920 --> 00:03:42.300 Let's use the same condition. 00:03:42.810 --> 00:03:44.650 Believe in your dream. 00:03:45.750 --> 00:03:46.310 OK. 00:03:46.620 --> 00:03:50.520 And we're going to have a question mark after that. 00:03:50.550 --> 00:04:02.190 So it's like we are saying is this condition true question mark if yes OK then we want to have this 00:04:02.190 --> 00:04:06.190 value able example. 00:04:06.210 --> 00:04:10.870 Otherwise you know use caller. 00:04:11.380 --> 00:04:12.600 OK. 00:04:12.880 --> 00:04:18.520 And then we get to rights the other values right. 00:04:18.770 --> 00:04:20.130 So if you echo 00:04:23.010 --> 00:04:23.490 X 00:04:29.000 --> 00:04:37.780 Let's check we can see that X equals B because our condition is false. 00:04:37.800 --> 00:04:38.850 All right. 00:04:39.720 --> 00:04:40.630 OK. 00:04:41.100 --> 00:04:41.350 OK. 00:04:41.370 --> 00:04:53.220 Now we are going to use if else but we are going to use another key word it's else if and if we have 00:04:55.500 --> 00:04:57.590 more than two conditions so. 00:04:57.750 --> 00:05:04.170 So for example if we said the three sets a variable temperature 00:05:07.060 --> 00:05:08.430 225. 00:05:08.880 --> 00:05:09.400 OK. 00:05:09.560 --> 00:05:17.460 And then we say if the temperature is less than 15. 00:05:18.840 --> 00:05:28.930 Ok then do this else do that's what we want to check. 00:05:28.950 --> 00:05:37.110 Also if the temperature is greater than 30 and also we want to check if it's a bridge is between 15 00:05:37.320 --> 00:05:38.890 and 30. 00:05:38.910 --> 00:05:40.300 So what we're going to do going to do. 00:05:40.300 --> 00:05:41.300 Else if. 00:05:41.760 --> 00:05:41.980 OK 00:05:45.210 --> 00:05:48.990 we're going to have our condition. 00:05:49.650 --> 00:05:53.920 So temperature greater than 30. 00:05:54.690 --> 00:05:59.480 And then we have else that do that's OK. 00:05:59.790 --> 00:06:08.060 So if the temperature is less than 15 then we can rise for example echo 00:06:08.270 --> 00:06:15.200 . 00:06:19.120 --> 00:06:20.760 It is cold. 00:06:21.140 --> 00:06:25.010 OK. 00:06:29.580 --> 00:06:37.760 If it's greater than that they see it go it is hot and else echo. 00:06:37.950 --> 00:06:42.940 The temperature is medium. 00:06:44.680 --> 00:06:50.340 OK assuming that I can see the temperature is medium 00:06:54.900 --> 00:06:58.590 the temperature is between 15 and 30. 00:06:59.310 --> 00:07:00.810 OK. 00:07:01.000 --> 00:07:01.530 All right. 00:07:01.680 --> 00:07:05.840 Now we're going to move to using a switch. 00:07:06.450 --> 00:07:12.530 So as we have covered this in javascript is more or less the same syntax. 00:07:12.700 --> 00:07:16.450 So let's define a variable strength 00:07:19.440 --> 00:07:22.490 and we're going to set it to the leaf. 00:07:23.000 --> 00:07:24.960 OK. 00:07:25.470 --> 00:07:27.090 That is a strength. 00:07:27.410 --> 00:07:35.140 It's when you believe in your goal it is really important to be successful. 00:07:35.190 --> 00:07:41.930 Now the syntax for the switch is going to be the keyword switch. 00:07:42.320 --> 00:07:43.120 OK. 00:07:43.200 --> 00:07:49.270 Followed by the very well we want to check. 00:07:49.500 --> 00:07:50.680 OK. 00:07:50.870 --> 00:07:53.820 In our case its strength. 00:07:53.900 --> 00:07:59.420 I'm going to put it between penances and then after that we're going to have curly brackets. 00:08:00.000 --> 00:08:06.060 And then inside our curly brackets we're going to have all the cases possible for our variable strength 00:08:06.060 --> 00:08:06.620 . 00:08:06.690 --> 00:08:08.820 So the first case let's have 00:08:12.160 --> 00:08:13.820 belief. 00:08:14.000 --> 00:08:14.780 OK. 00:08:15.000 --> 00:08:22.790 And that's going to be followed by one on and then we say what we want to execute. 00:08:22.830 --> 00:08:28.420 If our variable strength equals belief. 00:08:28.690 --> 00:08:29.950 OK. 00:08:31.410 --> 00:08:32.290 So. 00:08:32.790 --> 00:08:38.890 So you going to echo something and then we break. 00:08:40.470 --> 00:08:41.680 OK. 00:08:41.700 --> 00:08:45.180 So break means that we're going to go out of our 00:08:50.190 --> 00:08:52.730 code inside the curly brackets. 00:08:53.190 --> 00:08:55.990 So we're just going to jump everything else. 00:08:56.040 --> 00:08:56.610 All right. 00:08:56.860 --> 00:08:58.900 So let's have another case 00:09:07.880 --> 00:09:10.810 communication. 00:09:11.020 --> 00:09:13.610 That's another good strength. 00:09:14.350 --> 00:09:15.660 OK. 00:09:15.690 --> 00:09:17.400 And here's another one 00:09:25.770 --> 00:09:28.240 petition. 00:09:29.670 --> 00:09:32.700 OK let's have another one 00:09:37.260 --> 00:09:39.780 determination. 00:09:41.730 --> 00:09:42.750 OK. 00:09:43.440 --> 00:09:44.580 And finally 00:09:48.330 --> 00:09:55.250 we're going to have the default statements and the default is going to be something. 00:09:55.440 --> 00:09:55.970 OK. 00:09:56.130 --> 00:10:02.110 So if he's not of those then we're going to excuse the default statements. 00:10:02.130 --> 00:10:07.030 And after that we break OK. 00:10:07.980 --> 00:10:11.010 So let's go back to our echo statements. 00:10:11.040 --> 00:10:18.760 So the first one is have a paragraph saying for example you have 00:10:22.170 --> 00:10:29.240 core values that's unchanging. 00:10:30.010 --> 00:10:30.890 OK. 00:10:30.930 --> 00:10:36.280 They will define your purpose in life. 00:10:37.910 --> 00:10:39.000 OK. 00:10:39.350 --> 00:10:55.190 And the second one is a program that will destroy you easily put your thoughts into words. 00:10:55.470 --> 00:10:58.370 You are a good presence. 00:11:00.000 --> 00:11:02.240 OK. 00:11:02.280 --> 00:11:14.850 And this one say you say Boga and it's right. 00:11:15.480 --> 00:11:23.860 You measure your progress against the progress of others 00:11:26.470 --> 00:11:27.640 . 00:11:28.340 --> 00:11:36.780 You try to win first place. 00:11:37.170 --> 00:11:38.460 OK. 00:11:39.530 --> 00:11:41.800 So let's get rid of this one. 00:11:42.330 --> 00:11:43.860 And the defaults let's say 00:11:50.090 --> 00:11:51.430 two is a trend 00:11:54.070 --> 00:11:59.160 you have many. 00:12:00.210 --> 00:12:00.880 OK. 00:12:01.140 --> 00:12:04.480 Now if we save and refresh the page. 00:12:05.630 --> 00:12:15.790 So since our value is belief or the strength variable we've caused this message which corresponds to 00:12:16.130 --> 00:12:16.480 this one