@@ -78,3 +78,96 @@ Topics included/covered
7878- ** Example** : Variables are like ` box or an envelope ` which we use to ` organize various kinds of stuff ` and put a ` label ` on each box or an envelope
7979- ** Example** : Variable declaration and assignment is just ` like Maths & Algebra ` : ` x = 10 ` ; and in JavaScript we write ` var x = 10; `
8080> ** Note** : Depending on programming language, the different assignment operator like ` equal to = ` or ` colon : ` is used to assign value to a variable
81+
82+ - For learning/understanding purpose/instance, lets consider the following JavaScript snippet:
83+ ``` js
84+ // javascript variables - variables defined to hold different types of data
85+ var techName = ' JavaScript' ; // String literal
86+ var version = 6 ; // Number literal
87+ var isDone = true ; // Boolean literal
88+
89+ console .log (' Learning ' + techName+ version);
90+
91+ var firstName = ' Dinanath ' ;
92+ let lastName = ' Jayaswal'
93+ const fullName = firstName + lastName
94+ ```
95+
96+
97+ > ** Syntax & Example** : ` 1.1-javascript-variable.html `
98+
99+ ``` html
100+ <!DOCTYPE html>
101+ <html lang =" en" >
102+
103+ <head >
104+
105+ <meta charset =" UTF-8" >
106+ <meta name =" viewport" content =" width=device-width, initial-scale=1.0" >
107+ <meta http-equiv =" X-UA-Compatible" content =" ie=edge" >
108+ <title >1.1-javascript-variable.html</title >
109+
110+ <!-- internal style -->
111+ <style >
112+ /* css selector: { property:value; } */
113+ body {
114+ font-family : arial ;
115+ }
116+ </style >
117+
118+ </head >
119+
120+ <body >
121+
122+
123+ <!-- include external JavaScript - body section -->
124+ <script src =" ./1.1-script.js" ></script >
125+
126+ </body >
127+
128+ </html >
129+ ```
130+
131+ > ** Syntax & Example** : ` 1.1-script.js `
132+
133+ ``` js
134+ // external js file
135+ // Write all JavaScript code here
136+
137+ // variables defined to hold different types of data
138+ var techName = ' JavaScript' ; // String literal
139+ var version = 6 ; // Number literal
140+ var isDone = true ; // Boolean literal
141+
142+ console .log (' Learning ' + techName+ version);
143+
144+ // ------------------------------
145+
146+ // Declaring Variable
147+ var userName;
148+
149+ // Assigning value
150+ userName = ' Dinanath' ;
151+
152+ console .log (' Welcome ' + userName);
153+
154+ // ------------------------------
155+
156+ // Declaring multiple variables
157+ var firstName = ' Dinanath' , lastName = ' Jayaswal' , age = 35 , isMarried = ' true' ;
158+
159+ // Declaring multiple variables in multiple lines for readability
160+ /* var firstName = 'Dinanath',
161+ lastName = 'Jayaswal',
162+ age = 35,
163+ isMarried = 'true'; */
164+
165+ console .log (' I am ' + firstName + ' ' + lastName);
166+ ```
167+
168+ <p >
169+ <figure >
170+ <img src="_images-css-variables/1.1-javascript-variable.png" alt="JavaScript variables declaration and use" title="JavaScript variables declaration and use" width="1000" border="2" />
171+ <figcaption> Image - JavaScript variables declaration and use </figcaption>
172+ </figure >
173+ </p >
0 commit comments