In order to bring our project to number two alive, we need to work with prompts.
A prompt is a sort of interaction with the end user, so I'm asking the end user to type some information
and I need to install.
Store that information into variables.
So the project that I have right now is I have the same index HTML file linking the main dot JS.
My style CSS file is totally empty and the main dot JS file is also empty.
So the first thing I'm going to do is create a variable called first.
First name.
And instead of typing my first name over here, I'm going to ask the JavaScript to prompt a message
asking for the first name.
The way I do that is I use the prompt function inside of the prompt to function, I can type whatever
the text that I want, and this text is going to be showing the top of the prompt that shows into the
page.
So my text was Please.
Enter your first name calling and space.
So when whenever they type the first name, it won't be together with the column.
Yeah, Just always leave a space and just to make sure I can.
Just to make sure I'm storing the information, type it from the user to the variable.
I'm going to log console, log this first name.
Perfect.
So this is my code.
Let's try.
Let's see if it's working.
I'm going to save the change and immediately the prompt is working.
Please enter your first name.
I entered the name and my name should be showing into the console right now, which it is line number
two of the main JS file.
So the prompt function works and you may be thinking what is a function?
A function is a set of either rules or tasks pre determined by the JavaScript, for example.
So let's say when you, when you're watching TV, you have a remote control and then you change the
channels.
Yeah.
The act of changing the channels means you are executing a function, a function inside of the remote
and everything that he has.
But you actually executing triggering function same over here.
Prompt There are a lot of codes inside of the prompt here, but they bundle those together into a function
and then you can use the function anywhere in your code.
It's very easy.
First one is done.
So let me make our life easier here and get the first one copy and paste down here because I need another
two times.
First one last name and age First, let's name an age.
Please enter your.
Last name.
Please enter your.
H Och, let me save that.
Before I save that, let me just duplicate.
And then one more time, the console.
I didn't copy.
I didn't copy that.
So let me copy that.
And so over here and over here.
There we go.
So the first variable is the first name and then the last name.
And then the last one is the h oc saving the config.
And please enter your first name, Andrea.
Last name Iacono and your age, 28 years old.
Here we are.
I don't know if I'm on the same lines, but at least I'm getting the result.
The only problem is I'm getting the actual age.
I'm not getting the plus two, but I'm going to leave the task for the next class.
Right now, the code that I have is three variables prompting a text.
You enter the text, the text is stored into the variable and the variables showing into the console
log.
So that's it for now.
Let's go for the next class where I can solve the mathematical problem of adding plus to into the H.