Hello Programming
Would you like to react to this message? Create an account in a few clicks or log in to continue.

JS Variables

+2
JasonOmeter
Admin
6 posters

Page 1 of 2 1, 2  Next

Go down

JS Variables Empty JS Variables

Post by Admin Wed Oct 11, 2017 1:03 pm

JavaScript Variables

JavaScript variables are containers for storing data values.

In this example, x, y, and z, are variables:
Example
var x = 5;
var y = 6;
var z = x + y;

From the example above, you can expect:

x stores the value 5
y stores the value 6
z stores the value 11

JavaScript Identifiers

All JavaScript variables must be identified with unique names.

These unique names are called identifiers.

Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).

The general rules for constructing names for variables (unique identifiers) are:

Names can contain letters, digits, underscores, and dollar signs.
Names must begin with a letter
Names can also begin with $ and _ (but we will not use it in this tutorial)
Names are case sensitive (y and Y are different variables)
Reserved words (like JavaScript keywords) cannot be used as names

For any clarifications you can leave your comment below. Laughing

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by JasonOmeter Fri Oct 13, 2017 7:49 pm

Tnx for the information Ma'am, i have a question for you maam,
what if i assign value of
var x = "33";
var y = 33;
var x = x + y;

what will be the answer maam? and what is the difference between "33" to  33 without quotation?

JasonOmeter
Master
Master

Posts : 7
Join date : 2017-10-13

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Fri Oct 13, 2017 7:54 pm

JasonOmeter wrote:Tnx for the information Ma'am, i have a question for you maam,
what if i assign value of
var x = "33";
var y = 33;
var x = x + y;

what will be the answer maam? and what is the difference between "33" to  33 without quotation?

Good Evening Jason! Numbers are written without quotes. If you put a number in quotes, it will be treated as a text string. Therefore, if you run the program the answer will be 3333 because the variable you assign in x is treated as a text string it will not be added to 33.

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by EzequielGo Sat Oct 14, 2017 1:58 pm

Is the assignment operator included in js variables?

EzequielGo
Master
Master

Posts : 13
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by SarahMae Sat Oct 14, 2017 2:08 pm

Can I create my own Javascript variable?

SarahMae
Master
Master

Posts : 9
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Sat Oct 14, 2017 2:27 pm

EzequielGo wrote:Is the assignment operator included in js variables?

Hello Ezequiel Smile Yes dear, the Assignment Operator is included in JavaScript Variables.

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Sat Oct 14, 2017 2:32 pm

SarahMae wrote:Can I create my own Javascript variable?

Hi Sarah! Yes of course! You can create your own JS Variables Smile

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by SarahMae Sat Oct 14, 2017 4:21 pm

Admin wrote:
SarahMae wrote:Can I create my own Javascript variable?

Hi Sarah! Yes of course! You can create your own JS Variables Smile

Can you please show me how to create my own javascript variable?

SarahMae
Master
Master

Posts : 9
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by SarahMae Sat Oct 14, 2017 4:21 pm

Admin wrote:
EzequielGo wrote:Is the assignment operator included in js variables?

Hello Ezequiel Smile Yes dear, the Assignment Operator is included in JavaScript Variables.

What is assignment operator?

SarahMae
Master
Master

Posts : 9
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by EzequielGo Sat Oct 14, 2017 4:46 pm

Admin wrote:
EzequielGo wrote:Is the assignment operator included in js variables?

Hello Ezequiel Smile Yes dear, the Assignment Operator is included in JavaScript Variables.

Like how? What's the use of assignment operator Ma'am?

EzequielGo
Master
Master

Posts : 13
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Sat Oct 14, 2017 4:57 pm

SarahMae wrote:
Admin wrote:
SarahMae wrote:Can I create my own Javascript variable?

Hi Sarah! Yes of course! You can create your own JS Variables Smile

Can you please show me how to create my own javascript variable?

Creating a variable in JavaScript is called "declaring" a variable. You declare a JavaScript variable with the var keyword:, After the declaration, the variable has no value. Technically it has the value of undefined. To assign a value to the variable, use the equal sign:, You can also assign a value to the variable when you declare it:. In the example below, I create a variable called myName and assign the value "Kayganthe" to it. Razz

var myName = "Kayganthe";

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Sat Oct 14, 2017 4:59 pm

SarahMae wrote:
Admin wrote:
EzequielGo wrote:Is the assignment operator included in js variables?

Hello Ezequiel Smile Yes dear, the Assignment Operator is included in JavaScript Variables.

What is assignment operator?

In JavaScript, the equal sign (=) is an "assignment" operator, not an "equal to" operator.

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Clyntt Sat Oct 14, 2017 7:38 pm

Can we declare many variables in one statement? confused

Clyntt
Master
Master

Posts : 9
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Sat Oct 14, 2017 8:00 pm

Clyntt wrote:Can we declare many variables in one statement? confused

Yes dear, you can declare many variables in one statement Smile

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Clyntt Sat Oct 14, 2017 8:01 pm

Admin wrote:
Clyntt wrote:Can we declare many variables in one statement? confused

Yes dear, you can declare many variables in one statement Smile

Can you show me how Ma'am ?

Clyntt
Master
Master

Posts : 9
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Admin Sat Oct 14, 2017 8:05 pm

Clyntt wrote:
Admin wrote:
Clyntt wrote:Can we declare many variables in one statement? confused

Yes dear, you can declare many variables in one statement Smile

Can you show me how Ma'am ?

Just simply start the statement with var and separate the variables by comma. For Example: var person = "Kayganthe", myName = "Kayla", age = 19;

Did you get it?

Admin
Admin

Posts : 28
Join date : 2017-09-15

http://kaylajem.forumotion.asia

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Clyntt Sat Oct 14, 2017 8:07 pm

Admin wrote:
Clyntt wrote:
Admin wrote:
Clyntt wrote:Can we declare many variables in one statement? confused

Yes dear, you can declare many variables in one statement Smile

Can you show me how Ma'am ?

Just simply start the statement with var and separate the variables by comma. For Example: var person = "Kayganthe", myName = "Kayla", age = 19;

Did you get it?

Yes Maam! Razz Thanks for the information.

Clyntt
Master
Master

Posts : 9
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Anne Sat Oct 14, 2017 8:27 pm

Can strings be written in single quote?

Anne
Master
Master

Posts : 8
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by EzequielGo Sat Oct 14, 2017 8:37 pm

Anne wrote:Can strings be written in single quote?

Strings are written inside double or single quotes. It does not matter.

EzequielGo
Master
Master

Posts : 13
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Anne Sat Oct 14, 2017 8:41 pm

SarahMae wrote:
Admin wrote:
EzequielGo wrote:Is the assignment operator included in js variables?

Hello Ezequiel Smile Yes dear, the Assignment Operator is included in JavaScript Variables.

What is assignment operator?

Same question. What is the use of assignment operator?

Anne
Master
Master

Posts : 8
Join date : 2017-10-14

Back to top Go down

JS Variables Empty Re: JS Variables

Post by Sponsored content


Sponsored content


Back to top Go down

Page 1 of 2 1, 2  Next

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum