Skip to content

Commit 5f3b8c2

Browse files
committed
variable and constant
1 parent 74d26eb commit 5f3b8c2

File tree

6 files changed

+161
-1
lines changed

6 files changed

+161
-1
lines changed

02. Start Coding/img/img-01.png

7.22 KB
Loading

02. Start Coding/img/img-2.png

13.2 KB
Loading

02. Start Coding/note.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,30 @@ <h4 class="fs-4 mt-4">JavaScript Ouput</h4>
5959
document.getElementById("output").innerHTML = "Hello, World!";
6060
</code>
6161

62-
<p>Use <code>script</code> tag for writng javacript code in html</p>
62+
<p class="mb-0">Use <code>script</code> tag for writng javacript code in html</p>
63+
<p>Also you can use externel file write javacript code with script link</p>
64+
<img class="img-fluid col-md-6" src="img/img-01.png" alt="">
65+
66+
<h4 class="fs-4 mt-4">JavaScript Ouput</h4>
67+
<p>In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.[1][2] The syntax of comments in various programming languages varies considerably.</p>
68+
<code>//Single Line Comment</code>
69+
<p></p>
70+
<code>/*
71+
Mutiline <br>comment
72+
*/</code>
6373

74+
<h4 class="fs-4 mt-4">JavaScript User Input</h4>
75+
<p class="mb-0">We can use prompt function for javacript user input</p>
76+
<code>
77+
var x;<br>
78+
x = prompt("Enter your name: ");<br>
79+
console.log(x);<br>
80+
</code>
6481

82+
<p class="m-0"><b>Output</b></p>
83+
<code>Aktaruzzaman</code>
84+
<p><b>Example:</b></p>
85+
<img src="img/img-2.png" class="img-fluid col-md-6" alt="">
6586
</div>
6687

6788

03. Variables and Constant/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
<h1 id="showMessage"></h1>
10+
<!-- link javacript file -->
11+
<script src="js/script.js"></script>
12+
13+
</body>
14+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//Declare variables
2+
var var1 = 10;
3+
console.log(var1);
4+
5+
//Reassign variables
6+
var var2 = 10;
7+
var2 = 32;
8+
console.log(var2);
9+
10+
//Assign variables in another variable
11+
var2 = var1;
12+
console.log(var1);
13+
14+
// Declare const
15+
const CONS = 1;
16+
console.log(CONS);
17+
18+
//Incorrect declaration constant
19+
// const NUM;
20+
// NUM = 1;
21+
22+
23+
var a;
24+
var b = a;
25+
a =34;
26+
27+
console.log(b);

03. Variables and Constant/note.html

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Java Script Basics</title>
8+
9+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
10+
<style>
11+
* {
12+
margin: 0;
13+
padding: 0;
14+
}
15+
</style>
16+
17+
</head>
18+
19+
<body>
20+
21+
<div class="container">
22+
<div class="row">
23+
<h4 class="fs-4 mt-4">Variable</h4>
24+
<p>We can use var and let for declar a variable in javascript. var and let have some different. We can learn
25+
it after ES6 lesson</p>
26+
<p class="mb-0"><b>Declare a Variable</b></p>
27+
<code class="mb-3">
28+
var myName = "Aktaruzzaman";<br>
29+
var number = 1;
30+
</code>
31+
<p class="mb-0"><b>Reassign Variable</b></p>
32+
<code class="mb-3">
33+
var myName = "Aktaruzzaman";<br>
34+
myName = 35;<br>
35+
console.log(myName);<br><br>
36+
<b>ouput:</b>
37+
35
38+
</code>
39+
40+
<p class="mb-0"><b>Assign Variable in Another Variable</b></p>
41+
<code class="mb-3">
42+
var1 = 10; <br>
43+
var2 = 30; <br>
44+
var1 = var2; <br>
45+
console.log(var1, var2);
46+
<br><br>
47+
<b>ouput: </b>
48+
<span>10 10</span>
49+
</code>
50+
51+
<p class="mb-0"><b>JavaScript Identifiers(Rules)</b></p>
52+
<pre>
53+
All JavaScript variables must be identified with unique names.
54+
These unique names are called identifiers.
55+
Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
56+
57+
The general rules for constructing names for variables (unique identifiers) are:
58+
59+
* Names can contain letters, digits, underscores, and dollar signs.
60+
* Names must begin with a letter.
61+
* Names can also begin with $ and _ (but we will not use it in this tutorial).
62+
* Names are case sensitive (y and Y are different variables).
63+
* Reserved words (like JavaScript keywords) cannot be used as names.
64+
</pre>
65+
66+
<p class="mb-0"><b>JavaScript Identifiers(Rules)</b></p>
67+
<pre>
68+
* The const keyword was introduced in ES6 (2015)
69+
* Variables defined with const cannot be Redeclared
70+
* Variables defined with const cannot be Reassigned
71+
* Variables defined with const have Block Scope
72+
<b>Always declare a variable with const when you know that the value should not be changed.</b>
73+
</pre>
74+
75+
<b>Example:</b>
76+
<p class="mb-1">Correct Example:</p>
77+
<code>
78+
const PI = 3.14159265359
79+
</code>
80+
81+
<p class="mb-1">Incorrect Example:</p>
82+
<code>
83+
const PI = 3.141592653589793;<br>
84+
PI = 3.14; // This will give an error <br>
85+
PI = PI + 10; // This will also give an error <br>
86+
</code>
87+
<p class="m-0 mt-3"><b>Keywords:</b></p>
88+
<p>In programming, a keyword is a word with a specific meaning and purpose that is reserved by a programming language. Keywords are used in the syntax of a program to define its structure and flow, and to specify the operations it should perform. They are also known as reserved words.</p>
89+
</div>
90+
91+
92+
</div>
93+
94+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
95+
<p></p>
96+
</body>
97+
98+
</html>

0 commit comments

Comments
 (0)