1
00:00:00,690 --> 00:00:07,020
Welcome to our quick lesson about the JavaScript prompt, and this is going to be a lesson that is going

2
00:00:07,020 --> 00:00:13,140
to show you how you can create interaction with the user and also get information from that Web user

3
00:00:13,320 --> 00:00:19,500
and also why you need variables and a great example of what you can contained within a variable so called

4
00:00:19,500 --> 00:00:26,190
example of the prompt, similar to the alert, except it asks you a question and allows the user in

5
00:00:26,190 --> 00:00:27,360
order to respond.

6
00:00:27,390 --> 00:00:28,560
So that's the big difference there.

7
00:00:28,710 --> 00:00:32,400
And just like alert, you don't need to add window in front of it.

8
00:00:32,550 --> 00:00:36,890
And of course you can if you want to, but it's going to be the same thing as the alert.

9
00:00:37,290 --> 00:00:44,880
So the objective here is to add a variable using a prompt and create that variable from the response

10
00:00:44,880 --> 00:00:51,860
from the user and then output utilize that variable that came in from the prompt into the console.

11
00:00:51,870 --> 00:00:54,090
So we're going to write Welcome to my site.

12
00:00:54,360 --> 00:01:00,930
And the prompt is going to be asking for the user's name and it's going to be adding in a message which

13
00:01:00,930 --> 00:01:02,760
is going to be welcome to my site.

14
00:01:02,880 --> 00:01:07,710
And then all we're doing is using that variable and outputting it into the console.

15
00:01:07,920 --> 00:01:11,520
So great use of great example of how to use variables.

16
00:01:12,210 --> 00:01:15,240
And this is a quick peek at the code that we're going to be writing.

17
00:01:15,390 --> 00:01:16,920
So go ahead and pause the video.

18
00:01:17,100 --> 00:01:19,500
And coming up next, I'll show you the solution.

19
00:01:19,920 --> 00:01:26,240
The solution for this is to pick a variable name and we can just call it user name.

20
00:01:26,460 --> 00:01:27,960
So we're using prompt.

21
00:01:28,200 --> 00:01:31,560
And just a quick example of what prompt does.

22
00:01:31,770 --> 00:01:38,760
So just like what we saw with the alert, you can type a message here within the rounded brackets.

23
00:01:38,940 --> 00:01:44,190
And when you initialize that, you see that we get the popup, but it's different than the alert because

24
00:01:44,190 --> 00:01:46,740
it's got an input here area here.

25
00:01:47,220 --> 00:01:51,650
And if I type in a response, you're going to see that response gets returned back.

26
00:01:51,870 --> 00:01:53,400
So the same idea here.

27
00:01:53,520 --> 00:01:59,580
Whenever we use the prompt, then the response is going to get returned back as the value of the user

28
00:01:59,580 --> 00:01:59,800
name.

29
00:01:59,820 --> 00:02:01,380
So let's ask our question.

30
00:02:01,680 --> 00:02:02,990
What is your name?

31
00:02:03,300 --> 00:02:09,060
And as we progress through the course, there are better ways to create that user interaction and prompt

32
00:02:09,180 --> 00:02:10,800
really isn't used a whole lot.

33
00:02:10,920 --> 00:02:17,880
But we're just using that as a quick example of how to get a value into a variable and then utilize

34
00:02:17,880 --> 00:02:18,460
that value.

35
00:02:18,810 --> 00:02:23,040
So we're going to have another variable that we're setting up and this is going to be our message.

36
00:02:23,190 --> 00:02:26,940
And then we're consoling, logging out this information.

37
00:02:26,940 --> 00:02:34,470
So we've got our message first and we use the plus sign to concatenate a string with a user or with

38
00:02:34,470 --> 00:02:40,670
two variables together so we can do plus to concatenate it together.

39
00:02:40,700 --> 00:02:42,220
I'm going to just leave a space in there.

40
00:02:42,690 --> 00:02:43,860
So let's try that.

41
00:02:43,860 --> 00:02:44,970
It's only refresh.

42
00:02:45,270 --> 00:02:46,400
What is your name?

43
00:02:46,410 --> 00:02:47,430
So type in your name.

44
00:02:47,430 --> 00:02:49,800
If your name is Lawrence, you can type that in.

45
00:02:49,800 --> 00:02:52,920
Or you could use Lowrance if you want to come to my site.

46
00:02:52,920 --> 00:02:54,290
Lawrence So there we go.

47
00:02:54,510 --> 00:02:55,230
So try that.

48
00:02:55,240 --> 00:02:59,940
It's and coming up next, I'll show you a better way to do this, using a template literal.
