Hello and welcome.
In this video I will be explaining what an input is in computer programming.
What is an input programming an input is basically a way of receiving information from a user.
So there are times where you may have a computer program or an application that requires some data from
the user in order to output certain results.
So the way the way the computer does that is by input and there are different ways to input information
for the computer to use.
You may have come across some of the common input methods already.
So things like a phone you may have been on a Web site before where you had to complete a form or input
some details into a text box.
Those are methods of input because they captured the data from the user and then by hasty e-mail and
then use javascript to read the values of those input into your program or application in this video.
I'm going to illustrate how an input works by using a built in function in javascript is called the
prompt.
The prompt basically is used to box questions and get some information from the user.
So I'd be illustrating with a prompt to show you how to get some input or information from a user.
I have got my console open and I have gone to this Web site about column blank so that basically is
a blank page that you can use to experiment.
So I've opened up the console for this page here.
So I'm going to tie pin.
The simple prompt command is a prompt is a built in command or function in javascript that enables you
to get some input.
What that does it all you put in the message you want it to bring up an input box for the user to enter
some details.
So let me start by typing in the command which is prompt to typing P R O M prompt and then you have
to place inside the parentheses the text that you want displayed so I can just say Please
enter
your name or your first name up or call on there because it's a string or a text.
You have to enclose it in quotes.
So this here is a complete statement here which is a command a prompt this prompt here is a javascript
building function.
So this will display a pop up com like input box for you to enter some detail so press enter.
And this is what it will look like.
You can see this text here Please enter your first name.
That's it there.
So I just need to enter some details so I just say enter your first name just see Rick and click OK.
And that's basically it you can see here.
It's displayed the name here.
So whereby you're using it in programs normally is used in combination with a variable.
So you'll store the values in variables and then use it later in the program or in your application.
You can also ask questions like What is your age.
Get a user or visitor to enter that age in the box.
And then once they enter that computer captures some captures that information and then uses that some
way within the program or application or I want to do I want to make this a bit more creative.
So I want to create a situation where it captures the information the user enters captures our input
and then displayed something else.
So I'm gonna clear this console by just right clicking and going.
CLAIRE console.
So what I'm going to do I'm going to create a couple of variables and then is an alert box or console
or log to display the output.
So when typing V are basically via means far is short form for variable is a key word in JavaScript.
It is used to create a variable variable basically as a storage container where you can store data.
So I'm going to create a variable and I'm going to call it first name and I'm going to set that the
course to here is used to assign values to this to the variable so I'm going to set that to quote to
the prompt inside the prompt.
I'm going to say I'm going to put some quotes and I'm going to say enter your first name
and first name.
OK.
Port call on and I for my call on the end.
There is a tape I need to let you know in the console if you want to create multiple lines you hold
down the shift key on your keyboard and press enter and that will give you a few lines I'm going to
enter another variable by typing a V R and I'm going to call these variable greeting okay and I'm going
to set that to a course to do.
Hello.
Okay.
And to put quotes there and I'm going to do a plus.
This is known as concatenation the plus operate is an operator's code concatenation is basically used
to add text or strings together.
All right.
So basically what this what this is doing here.
This is a variable called first name.
And I've said it too of course to this function here.
So what happens.
The user will get a prompt is they enter your first name once they enter the first name it will store
the first name inside this variable called first name used in this assignment operator equals two is
used to assign values to variables.
So it will assign whatever is entered here into there and then this variable here I've set it to close
to her low plus first name.
So for example the first name is Joe Bloggs.
This greeting will of course to Hello plus Joe Bloggs.
So that's the way the variable is going to work.
So now if I press enter I will get this a lockbox where it says enter your first name which is this
tax.
So.
And Tom my first name.
Press.
OK.
You know saying on defined because that probably you have just entered it is captured and stored it
inside this variable called first name.
So if I want to get the value of this variable called greeting all I need to do I can make it display
in proper box.
I can just to alert and inside the parentheses I just typed in the name of the variable which is greeting
and semicolon and go to a pop up you can see here is saying hello Rick.
The trick here is capture the first name I entered here and saved it inside this variable called first
name.
Using this assignment operator.
And this here.
This is known as concatenation is added this text.
Hello to the value of entered here.
That was captured which is this.
So anyway you see a plus with text is known as concatenation.
Notice as the space between the halo and the Rick this is possible because of the space of left here
between these closing quotes.
If I hadn't left the space between the courts the halo and the Rick will be joined together.
So it's good to take note of that.
So that's it.
I hope this video has been useful in illustrating how the input works or input basically is used to
receive information from a user or a visitor.
Normally you would have forms on a web page that he uses can enter information and then javascript is
used to translate that information into the variables within the programs and then the program can use
that information.
But I've used a prompt command just to illustrate quickly how to capture information from a user.
Thanks for watching and bye for now.