WEBVTT

00:01.290 --> 00:07.710
I hope that you have done this just correctly or at least try to find a solution or make it find even

00:07.710 --> 00:09.120
a better solution for our task.

00:09.510 --> 00:12.010
But anyway, let's go ahead and do it step by step.

00:12.900 --> 00:17.090
So the first step was to create an array students instead.

00:17.100 --> 00:22.920
There are four items, which should be objects and have three properties, name square ones, Corto

00:23.430 --> 00:32.130
with the following values so right for students and pass the items as objects.

00:32.670 --> 00:37.680
We need to open curly braces and that create the properties name.

00:38.920 --> 00:39.340
John.

00:41.100 --> 00:42.540
Then score one.

00:44.560 --> 00:45.500
Forty seven.

00:47.070 --> 00:48.210
And score to.

00:49.950 --> 00:50.510
To six.

00:54.030 --> 00:56.850
Let's copy it and paste three times.

01:00.040 --> 01:01.810
We don't need this Colma here.

01:03.190 --> 01:06.730
And also change the values right here, Bob.

01:08.450 --> 01:13.100
And this course as twenty three and twenty four.

01:15.460 --> 01:16.480
Then, Nick.

01:18.550 --> 01:22.900
With course 40 and 35.

01:25.600 --> 01:27.310
Elder law student Alex.

01:29.810 --> 01:34.010
Change this course, you're right, 44 and 45.

01:35.330 --> 01:36.950
All right, the first up is done.

01:37.100 --> 01:38.540
The next is also very simple.

01:38.540 --> 01:43.160
One, we just need to create two arrays for scores and degrees.

01:43.640 --> 01:44.350
Let's do it.

01:44.360 --> 01:45.740
Create variables cause.

01:47.020 --> 01:47.530
And.

01:48.850 --> 01:54.220
Let's place here as items the passing limit's 91 81.

01:56.030 --> 01:56.360
One.

01:57.500 --> 01:59.900
61 and 51.

02:01.940 --> 02:04.970
Then create variable degrees and.

02:06.420 --> 02:07.020
Insert.

02:08.890 --> 02:09.550
Items.

02:11.910 --> 02:14.070
A, B, c.

02:16.000 --> 02:16.990
The anti.

02:17.980 --> 02:24.880
OK, let's see what is the next step we need to create function which will calculate total score for

02:24.880 --> 02:25.430
each student.

02:26.030 --> 02:27.760
It's also the very simple step.

02:28.120 --> 02:32.230
So create function and call it calculate some.

02:34.190 --> 02:40.990
This function will receive two parameters for score one and score two, so let's place them in kind

02:41.000 --> 02:41.630
of short way.

02:43.470 --> 02:51.710
Then inside the braces create new variable sum and assign to score one plus score to.

02:54.450 --> 02:57.960
And then in order to get the value some, we have to return it.

03:01.560 --> 03:06.120
All right, I'm sure that you didn't have any trouble to come to this point.

03:06.540 --> 03:09.890
Now it's time to start the main and more interesting part of this test.

03:10.590 --> 03:12.300
So we need to create a function.

03:12.300 --> 03:18.300
And using this function, we need to figure out which student has passed an exam and what kind of degree

03:18.300 --> 03:19.590
of diploma he has got.

03:20.130 --> 03:24.240
So creates new function and call it calculates final.

03:28.510 --> 03:34.420
In order to see the results and also test the codes that we are going to write, let's call this function

03:35.050 --> 03:36.940
right below the name of this function.

03:38.680 --> 03:44.240
As you have just seen, we have created the general function for calculating the total score of students.

03:44.950 --> 03:50.590
Now we're going to use follow up and emersion calculate some function in order to calculate the total

03:50.590 --> 03:57.280
score for each student and after that at the results at the new property for our objects on the fly.

03:58.940 --> 04:01.610
OK, let's do it first, create for Loop.

04:03.350 --> 04:05.750
Variable, i.e., close to zero.

04:06.840 --> 04:07.260
Then.

04:08.690 --> 04:13.100
As a condition, right, I is less than students that length.

04:15.910 --> 04:17.650
And then I plus plus.

04:20.550 --> 04:26.730
As we said, we are going to act as the new properties, some of score one and score two, so.

04:26.730 --> 04:30.840
Right students, I got some.

04:33.220 --> 04:39.690
You remember that we were using dot notation in order to access and also to add the properties to objects,

04:40.420 --> 04:43.890
you also see that calculate some function, returns the value some.

04:44.440 --> 04:51.550
And in order to assign it to new property, we need to call this function here and pass at the arguments,

04:51.880 --> 04:54.480
score one and score two for each student.

04:55.150 --> 04:56.860
So right to calculate some.

04:58.530 --> 05:05.130
And as an argument, right, students, I thought score one.

05:07.530 --> 05:09.150
And then students I.

05:10.320 --> 05:11.730
That's got to.

05:13.500 --> 05:20.130
So, again, calculator function gives us as a value the sum of score one and score two, and we assign

05:20.130 --> 05:23.460
it as a value to the newly created property.

05:23.460 --> 05:27.270
Some, let's say, Castle, what this code exactly does.

05:27.900 --> 05:28.630
Right, Castle?

05:28.640 --> 05:29.970
That students.

05:31.800 --> 05:38.850
Reload and you can see Arae with our objects, if you take a look, you will see that objects have a

05:38.850 --> 05:42.430
new property, some with total scores for students.

05:42.930 --> 05:46.230
And again, note that this property was created on the fly.

05:47.540 --> 05:54.470
All right, now we need to check if a student has passed an exam or not, we know that overlimit is

05:54.470 --> 05:55.730
51 points.

05:56.270 --> 06:01.220
So we need to check if some, of course, is greater than or equal to 51.

06:02.280 --> 06:09.420
So creative statement with the condition students, I thought some.

06:11.270 --> 06:14.120
Is greater than or equal to 51.

06:16.490 --> 06:23.510
If this condition is true, if a student has passed an exam, then log their result in council and write

06:24.290 --> 06:25.250
Castlewood log.

06:26.710 --> 06:28.630
Students I.

06:30.300 --> 06:32.310
And use your name property.

06:33.360 --> 06:36.060
Plus, past final exam.

06:37.660 --> 06:38.470
Successfully.

06:41.590 --> 06:48.610
Revolt and you see that we got results for three students, John, Nick and Alex, and he tells us that

06:48.610 --> 06:50.860
they have passed final exams successfully.

06:51.980 --> 06:53.100
All right, fine.

06:53.720 --> 06:59.120
The next step is to figure out what was the final score for each student and according to that score,

06:59.130 --> 07:04.400
what kind of degree of diploma this student has got for that, I'm going to use again, follow.

07:04.670 --> 07:11.330
But before I do that, I want to demonstrate, just for your information, how Facebook works inside

07:11.330 --> 07:13.900
another club that's right below.

07:13.940 --> 07:15.110
A simple example.

07:15.380 --> 07:18.160
But before that, let's make a little broader here.

07:20.040 --> 07:22.770
So create follow up, right?

07:23.190 --> 07:24.120
Very well, I.

07:25.470 --> 07:27.450
And assigned to its Disvalue 100.

07:28.790 --> 07:32.000
Then as a condition, right eye is less than.

07:33.250 --> 07:34.350
Hundred and five.

07:35.900 --> 07:37.130
And then I plus plus.

07:39.760 --> 07:42.040
Inside the loop, create another one.

07:43.490 --> 07:44.000
And.

07:45.050 --> 07:53.330
Let's use here as a counter variable, X assigned to role, then right to condition X is less than 10.

07:55.250 --> 07:56.600
And then X plus plus.

07:59.270 --> 08:01.850
Let's log in council, the variable X.

08:04.630 --> 08:05.200
And then.

08:07.360 --> 08:10.030
Right outside Castle Deathlok.

08:11.590 --> 08:14.770
I reload the page.

08:15.930 --> 08:23.580
So you see, we have numbers from zero to nine and then 100, then again, numbers from zero to nine,

08:24.150 --> 08:29.460
then hundred and one, and it continues like this until the condition becomes false.

08:30.510 --> 08:31.640
Let's see what has happened.

08:32.280 --> 08:37.130
Generally, people are sometimes confused with that case because they think that, well, first of all,

08:37.130 --> 08:43.980
look, does its first iteration I mean, when I is 100, then the second follow up does one iteration

08:43.980 --> 08:44.250
two.

08:44.880 --> 08:45.940
But it's not true.

08:46.830 --> 08:53.340
So when first loop does its first iteration, then for loop inside it does all its iterations.

08:54.000 --> 08:56.180
You can obviously see it in this example.

08:56.700 --> 09:03.630
So here during the first iteration, when I is 100, the following site does all the situations and

09:03.630 --> 09:05.520
gives us the numbers from zero to nine.

09:06.210 --> 09:10.560
And after that we have hundreds from the first iteration, which belongs to the first follow.

09:11.810 --> 09:12.490
Makes sense.

09:14.010 --> 09:22.890
OK, so we're going to use this case in our task, let's comment it out and go back to our task, create

09:22.900 --> 09:25.140
another follow up and use.

09:26.510 --> 09:29.600
Another counteracts assigned to it.

09:29.630 --> 09:30.150
Zero.

09:30.860 --> 09:33.670
We need this loop to iterate through a race course.

09:33.680 --> 09:36.950
So I'm going to use length property, of course, right.

09:36.950 --> 09:40.310
As a condition, X is less than Schaus thought length.

09:41.800 --> 09:43.270
And that X plus plus.

09:45.610 --> 09:51.310
Then we need to create another statement inside Fallujah using this statement, I'm going to compare

09:51.310 --> 09:56.900
total scores of the students to scores which actually define a degree of the diploma.

09:57.430 --> 09:57.820
So.

09:57.820 --> 10:00.730
Right, if they're students, I.

10:01.970 --> 10:02.780
Not some.

10:04.680 --> 10:08.100
Is greater than or equal to Schaus X.

10:10.810 --> 10:16.570
So if this condition is true, if total score of the student is greater than or equal to the items inside

10:16.570 --> 10:21.880
a racecourse, then we need to get the result with the score and the degree which we need to get from

10:21.880 --> 10:22.830
the eight degrees.

10:23.740 --> 10:30.130
You see that both arrays have the same length and therefore, if total score is greater than one of

10:30.130 --> 10:34.390
the items from scores, then we need to get its appropriate degree.

10:35.380 --> 10:41.980
So, for example, if students score is greater than 91, then it's really what degree of diploma will

10:41.980 --> 10:42.400
be a.

10:43.810 --> 10:47.920
Makes sense, so we need to write the following cost a lot like.

10:49.620 --> 10:50.010
Then.

10:51.020 --> 10:51.770
He has.

10:53.240 --> 10:56.930
And plus students, I told some.

10:58.670 --> 11:02.900
Then again, plus some texture points and he got diploma.

11:05.980 --> 11:07.030
With a degree.

11:08.550 --> 11:10.920
And then plus, degrease ex.

11:13.400 --> 11:19.730
Again, we use degrees with index number X because scores and degrees iRace have the same length.

11:20.990 --> 11:26.090
Reload and you see that we got results that you may were not expecting.

11:26.360 --> 11:27.260
Let's explain it.

11:27.260 --> 11:34.370
In case of John, we know that John has 93 points, which is greater than all the items in a race course.

11:34.770 --> 11:37.550
Therefore, the condition is true for all the iterations of.

11:38.270 --> 11:40.860
And that's why we got five results instead of one.

11:41.480 --> 11:46.880
So when the condition becomes true, then we need immediately to stop loop iterations.

11:47.130 --> 11:49.430
And for that we need brake statements.

11:51.630 --> 11:55.140
Let's reload, and he said that the problem is fixed.

11:56.610 --> 12:01.020
OK, let's make your little border for better readability.

12:05.190 --> 12:05.790
Reloj.

12:07.570 --> 12:09.430
Now it's much nicer.

12:10.510 --> 12:11.080
All right.

12:11.110 --> 12:16.420
Almost everything is done, but you see that Bob is missing because he's failed and we need to show

12:16.420 --> 12:22.930
it for that creative statement, which will be a part of first if statement where we have checked if

12:22.930 --> 12:24.820
students have passed an exam or not.

12:26.410 --> 12:28.300
And run in council.

12:29.410 --> 12:30.250
Students.

12:31.920 --> 12:35.610
I don't name plus got.

12:37.490 --> 12:44.120
Then plus in place here with some of scores, students, I taught some.

12:45.830 --> 12:48.260
And then plus points.

12:49.770 --> 12:54.170
Has failed and has to try next year.

13:00.040 --> 13:02.290
And then make again little border.

13:04.760 --> 13:06.380
Reload the page and.

13:07.540 --> 13:09.160
Here we have Bob to.

13:10.550 --> 13:13.670
Now we can say that finally our task is done.

13:15.270 --> 13:20.760
OK, I think that everything was clear for you, you can test again the code we have written on your

13:20.760 --> 13:21.060
own.

13:21.510 --> 13:25.260
Also, you can feel free to add something to improve this task.

13:26.210 --> 13:31.480
I hope that you have enjoyed it and now little quiz is waiting for you, so let's move on.
