WEBVTT

00:00.440 --> 00:02.300
We'll be covering a lot of ground.

00:02.310 --> 00:05.210
Sometimes it's hard to see where this is taking us.

00:05.250 --> 00:10.800
So just a quick reminder we need to go through the basics of the language we need to understand how

00:10.800 --> 00:18.370
we kobun javascript before we can jump into more complex projects such as an interactive Web site.

00:18.720 --> 00:24.060
Or if you want to get started with learning how to use javascript on the server side to create web applications

00:24.660 --> 00:31.860
or if you want to make a mobile app with DML 5 or a video game with HD and L5 we do need to go through

00:31.980 --> 00:33.840
all of this process.

00:33.900 --> 00:36.130
It's part of what needs to be learnt.

00:36.630 --> 00:45.600
So this lesson I want to cover to do a couple of examples of functions just to use some of the concepts

00:45.630 --> 00:46.990
we've been working on.

00:47.040 --> 00:49.110
It's still not going to be something applied.

00:49.110 --> 00:55.980
Something for the final user but I hope that by seeing these examples you get a bit more familiar with

00:55.980 --> 01:00.870
what we've been covering and kind of start to see what this can take us.

01:01.200 --> 01:03.480
So I'm going to create a couple of functions.

01:03.480 --> 01:10.040
One function will give me the message according to the final mark of the of the students.

01:10.110 --> 01:15.090
Basically I wanted to I wanted to combine functions and conditions in a couple of examples.

01:15.090 --> 01:21.750
The other one will give me like like a name with a title for instance if I say Pablo and I say MALE

01:21.910 --> 01:28.590
I'm going to give me a service called Mr. Pablo or give me or give me a female title if I write that

01:28.590 --> 01:31.150
it's a female.

01:31.350 --> 01:35.010
So let's let's get started let's get started.

01:35.010 --> 01:45.790
The function will be final mark final message and it will receive as an input the mark inside of this

01:45.790 --> 01:46.340
function.

01:46.370 --> 01:50.140
We want to use the switch statement as we did before.

01:51.190 --> 01:55.500
And we've got to have some some cases in case it's an A.

01:56.020 --> 01:59.440
We're going to return a value to the user.

01:59.440 --> 02:04.200
We're going to return past.

02:04.730 --> 02:08.250
And let's actually let's.

02:08.250 --> 02:11.290
Let's say that is in a variable variable a.

02:11.620 --> 02:22.750
We'll have this break and then we'll do it case if it's a B we'll say that barely passed

02:27.260 --> 02:39.060
and we'll have a default for other cases that will be I don't know how you did in the course break.

02:39.640 --> 02:46.420
And after that after our switch we will actually this is misplaced.

02:46.640 --> 02:50.440
That's why it's complaining that you go there.

02:50.690 --> 02:54.230
Now we are just going to return a value.

02:55.580 --> 02:57.560
Let's use this.

02:57.650 --> 03:04.430
How about What do I get if I see how I can just pick it from here.

03:04.880 --> 03:09.620
If I got an AA and somebody else got

03:12.580 --> 03:24.510
say a B or A C look in the console past barely past I don't know how you did because I'm just putting

03:24.510 --> 03:26.510
in something that doesn't exist.

03:28.670 --> 03:29.590
So that's pretty simple.

03:29.590 --> 03:37.410
See how you can combine functions with conditions makes things a bit more and more complex more interesting.

03:37.430 --> 03:44.240
There's a whole lot of things that you can do but by just using functions and conditions and variables

03:44.270 --> 03:47.350
you can make an entire text based game.

03:47.350 --> 03:57.290
For instance our second function will be name with title and it's going to receive two parameters.

03:57.290 --> 03:59.780
The first parameter is going to be the name.

03:59.780 --> 04:05.410
The second one is going to be the gender.

04:05.810 --> 04:23.890
So if gender equals male will return a full name will be Mr. space and then plus name Else.

04:23.950 --> 04:31.410
Else if gender equals F. Will do returned.

04:32.540 --> 04:40.290
Ms name will have a case for it when we don't know what it is.

04:40.470 --> 04:47.230
And so we'll do it like this name.

04:47.610 --> 04:49.290
Let's try that out.

04:49.350 --> 04:58.600
Konsole name with not completing it but will complete it ourselves name with Title.

04:58.860 --> 05:00.690
Oh excuse me help here.

05:00.720 --> 05:03.350
There is a parameter that's the name.

05:03.380 --> 05:15.390
So when I enter a string that will be called John and the gender will be male.

05:15.540 --> 05:17.430
Reload the page to see what we get.

05:17.470 --> 05:22.340
Mr. John let's do.

05:23.440 --> 05:34.200
Susan and I get this on if we type if we type something else we'll just get it doesn't know what it

05:34.200 --> 05:34.640
is.

05:34.650 --> 05:37.340
Just put a question mark.

05:38.280 --> 05:46.980
So see how you can combine these these functions with conditions variables to a whole bunch of stuff.

05:47.100 --> 05:51.050
You can also nest functions inside other functions.

05:51.780 --> 05:57.430
I recommend that you practice a little bit help play with the code of the lessons.

05:57.690 --> 06:02.360
Create a couple of functions of your own combining functions and conditions.

06:02.350 --> 06:09.170
And when you feel confident with that and let's continue with more javascript programming concept.
