1
00:00:00,570 --> 00:00:05,180
So let's go ahead and create the solution to this javascript stocker exercise.

2
00:00:05,550 --> 00:00:07,010
So I have a stalker.

3
00:00:07,020 --> 00:00:11,640
Each time I'll file and I'm going to fill it out with my basic boiler plate.

4
00:00:11,910 --> 00:00:12,630
Give it a title

5
00:00:15,720 --> 00:00:25,270
and let's put a simple H-1 J.S. stocker solution just so that we can see the page load.

6
00:00:25,290 --> 00:00:29,160
Now I'm going to make my javascript file new file.

7
00:00:29,160 --> 00:00:32,170
I'm going to save it and I'll just call it script.

8
00:00:32,280 --> 00:00:34,930
Us in the same directory.

9
00:00:36,030 --> 00:00:39,630
And I'm just going to put a console log in here just to make sure it works.

10
00:00:39,690 --> 00:00:46,710
Cancel that log from the script file and save.

11
00:00:46,710 --> 00:00:51,270
Now let's go open this in the browser.

12
00:00:51,270 --> 00:00:56,970
We won't see anything unless they open the console and I still don't see anything because I haven't

13
00:00:56,970 --> 00:01:01,950
connected my files so that's the next part I'm going to go here.

14
00:01:01,950 --> 00:01:12,960
I had my script Reg source equals script dot J.S. make sure those match script js script.

15
00:01:13,110 --> 00:01:15,700
Yes go refresh the page.

16
00:01:16,020 --> 00:01:20,500
Now I get my constant log from the script file.

17
00:01:20,540 --> 00:01:22,920
So now let's work on the logic here.

18
00:01:22,920 --> 00:01:27,980
So the very first thing that needs to happen we need to ask for the first name.

19
00:01:28,440 --> 00:01:34,030
So I'm going to set a variable first name because prompt.

20
00:01:34,230 --> 00:01:35,640
What is your first name

21
00:01:39,180 --> 00:01:40,820
and save.

22
00:01:41,320 --> 00:01:44,780
And then do the same thing for a last name.

23
00:01:45,360 --> 00:01:46,410
Last name prompt.

24
00:01:46,410 --> 00:01:49,400
What is your last name.

25
00:01:49,530 --> 00:01:51,240
And lastly the same thing for.

26
00:01:51,240 --> 00:01:54,000
Age.

27
00:01:54,000 --> 00:02:02,250
What is your age and save so that will get those three pieces of data and you can see that here if I

28
00:02:02,250 --> 00:02:09,430
refresh it asked me three times and then it doesn't do anything with that.

29
00:02:09,450 --> 00:02:15,030
So now we want to print out the form name so that's a con. But log.

30
00:02:15,030 --> 00:02:18,660
Not an alert because we don't want to pop up just to cancel that log.

31
00:02:18,960 --> 00:02:30,870
And let's make the string here your full name is and then make sure we have the space here plus first

32
00:02:30,870 --> 00:02:35,700
name and let's just start with that and see what we get.

33
00:02:35,700 --> 00:02:42,350
So I'll refresh the page rusty steel 3.

34
00:02:42,450 --> 00:02:43,840
Your full name is Rusty.

35
00:02:43,980 --> 00:02:45,250
OK so that's working.

36
00:02:45,360 --> 00:02:52,140
Now we just want to add in last name but remember we need the space here because this will just take

37
00:02:52,200 --> 00:02:54,250
Rusty and steel and smushed them together.

38
00:02:54,510 --> 00:02:58,020
So to do that we can just add in a string.

39
00:02:58,290 --> 00:03:00,840
That's all it is is a space.

40
00:03:00,840 --> 00:03:07,470
So your full name is space first name plus space plus last name.

41
00:03:08,460 --> 00:03:15,460
And if we run this and refresh rusty steel 3.

42
00:03:15,900 --> 00:03:20,500
Your full name is rusty steel.

43
00:03:20,580 --> 00:03:34,550
Next up we're going to print out the age so that's another council about log you are plus age plus we

44
00:03:34,570 --> 00:03:36,320
use space afterwards.

45
00:03:36,540 --> 00:03:38,980
Years old just like that.

46
00:03:39,000 --> 00:03:51,630
So you are space age space years old and if we run this now and refresh rusty steel 3.

47
00:03:51,750 --> 00:03:53,770
Your full name is rusty steel.

48
00:03:53,880 --> 00:03:57,870
You are three years old and that's it.

49
00:03:57,870 --> 00:04:04,500
There is one small change that we could make so you could argue that this is a little bit clunky here

50
00:04:04,510 --> 00:04:04,540
.

51
00:04:04,540 --> 00:04:05,910
So it's kind of cluttered.

52
00:04:06,180 --> 00:04:09,050
So we could just pull this out into its own variable.

53
00:04:09,090 --> 00:04:17,130
So I'm going to cut that out and just make a variable called full name and set it equal to that value

54
00:04:17,130 --> 00:04:21,000
of first name plus space plus the value of last name.

55
00:04:21,150 --> 00:04:24,410
And then here I can just print full name.

56
00:04:24,510 --> 00:04:26,530
So this is just a matter of preference.

57
00:04:26,880 --> 00:04:30,420
It's not right or wrong it's just whatever you think looks better.

58
00:04:30,420 --> 00:04:35,460
And I happen to think this is nicer because now we have this full name variable that has the entire

59
00:04:35,460 --> 00:04:36,990
file name stored in it.

60
00:04:37,440 --> 00:04:47,110
So just to prove to you nothing changed I refresh Rustie still 3 and we get the same output.
