Skip to content

Commit 5edd74c

Browse files
added
1 parent cc48ac0 commit 5edd74c

File tree

12 files changed

+372
-0
lines changed

12 files changed

+372
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Variable Declaration</title>
6+
<link rel="stylesheet" href="05_styles.css">
7+
</head>
8+
<body>
9+
10+
<h2>Variable Declaration Example</h2>
11+
<div>
12+
<h1 id="display"></h1>
13+
</div>
14+
15+
<script src="05_script.js"></script>
16+
</body>
17+
</html>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Create two variables and display their sum
2+
var a = 10;
3+
var b = 20;
4+
var sum = a + b;
5+
console.log("Sum of a , b is : " + sum);
6+
document.getElementById('display').innerHTML = "Sum of a , b is : " + sum;
7+
8+
// Find the biggest value between 2 numbers
9+
var p = 20;
10+
var q = 30;
11+
if(p > q){
12+
console.log("The big value is : " + p);
13+
}
14+
else{
15+
console.log("The big value is : " + q);
16+
}
17+
18+
// Find the biggest value among 3 numbers
19+
var x = 10;
20+
var y = 20;
21+
var z = 30;
22+
if(x > y && x > z){
23+
console.log("The Biggest value is : " + x);
24+
}
25+
else if(y > z){
26+
console.log("The Biggest value is : " + y);
27+
}
28+
else{
29+
console.log("The Biggest value is : " + z);
30+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
body{
2+
margin: 0;
3+
font-family: "Comic Sans MS",sans-serif;
4+
}
5+
h2{
6+
background-color: lightsalmon;
7+
text-align: center;
8+
padding: 10px;
9+
}
10+
div{
11+
background-color: orange;
12+
padding: 10px;
13+
text-align: center;
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en-US">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS DataTypes</title>
6+
<link rel="stylesheet" href="06_styles.css">
7+
</head>
8+
9+
<body>
10+
11+
<h2>JS Data types Example</h2>
12+
<div>
13+
<h1 id="display"></h1>
14+
</div>
15+
16+
<script src="06_script.js"></script>
17+
</body>
18+
</html>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// number example
2+
var age = 25;
3+
console.log("age : " + age + " Type of a : " + typeof age);
4+
5+
// String Examples
6+
var greeting = 'Good Morning';
7+
console.log("Greeting : " + greeting + " datatype : " + typeof greeting);
8+
9+
// boolean Examples
10+
var isJSEasy = true;
11+
console.log("isJSEasy : " + isJSEasy + " datatype : " + typeof isJSEasy);
12+
13+
// Undefined Example
14+
var someVar;
15+
console.log("someVar : " + someVar + " datatype " + typeof someVar);
16+
17+
// null example
18+
var abc = null;
19+
console.log("abc : " + abc + " datatype : " + typeof abc);
20+
21+
// reassignment example of variables
22+
var xyz;
23+
console.log('xyz : ' + xyz);
24+
25+
xyz = 10;
26+
console.log('xyz : ' + xyz);
27+
28+
xyz = 'test';
29+
console.log('xyz : ' + xyz);
30+
31+
xyz = true;
32+
console.log('xyz : ' + xyz);
33+
34+
xyz = null;
35+
console.log('xyz : ' + xyz);
36+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
body{
2+
margin: 0;
3+
font-family: "Comic Sans MS",sans-serif;
4+
}
5+
h2{
6+
background-color: lightsalmon;
7+
text-align: center;
8+
padding: 10px;
9+
}
10+
div{
11+
background-color: orange;
12+
padding: 10px;
13+
text-align: center;
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS Operators</title>
6+
<link rel="stylesheet" href="07_styles.css">
7+
</head>
8+
<body>
9+
10+
<h2>JS Operators Example</h2>
11+
<div>
12+
<h1 id="display"></h1>
13+
</div>
14+
15+
<script src="07_script.js"></script>
16+
</body>
17+
</html>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Assignment operator =
2+
var num1 = 10;
3+
console.log("num1 : " + num1);
4+
5+
// Arithmetic operators + - * /
6+
var a = 10;
7+
var b = 20;
8+
var sum = a + b;
9+
console.log("a + b : " + sum);
10+
11+
var mul = a * b;
12+
console.log("a * b : " + mul);
13+
14+
// Short hand math += , -= , *= , /=
15+
a = 10;
16+
b = 20;
17+
var add = 0;
18+
add = add + (a + b); // long way
19+
add += (a + b); // short hand math
20+
21+
console.log('add : ' + add);
22+
23+
// Conditional operators < , > , <= , >= , !=
24+
var age = 25;
25+
if(age <= 18){
26+
console.log("Your are Minor");
27+
}
28+
else{
29+
console.log("You are Major");
30+
}
31+
32+
// Unary Operator ++ , -- (pre , post)
33+
var x = 10;
34+
x = x + 1; //11
35+
x += 1; // 12
36+
x++; // 13
37+
console.log('x : ' + x); // 13
38+
39+
// Logical operators AND , OR
40+
var inRelation = true;
41+
var parentsAgreed = false;
42+
if(inRelation && parentsAgreed){
43+
console.log("Get Marry Soon");
44+
}
45+
else{
46+
console.log("Wait until parents agreed");
47+
}
48+
49+
// String Concatenation Operator
50+
var str = "10" + 10 + 10 + 10;
51+
console.log('str : ' + str);
52+
53+
// Ternary operator (? :)
54+
age = 25;
55+
56+
(age <= 18) ? console.log("You are Minor") : console.log("You are Major");
57+
58+
// Type of operator
59+
var abc;
60+
console.log('value : ' + abc + ' Data Type :' + typeof abc);
61+
62+
abc = 10;
63+
console.log('value : ' + abc + ' Data Type :' + typeof abc);
64+
65+
abc = 'test';
66+
console.log('value : ' + abc + ' Data Type :' + typeof abc);
67+
68+
abc = true;
69+
console.log('value : ' + abc + ' Data Type :' + typeof abc);
70+
71+
abc = null;
72+
console.log('value : ' + abc + ' Data Type :' + typeof abc);
73+
74+
// == operator
75+
a = 10;
76+
b = "10";
77+
if(a == b){
78+
console.log("Both are Equal");
79+
}
80+
else{
81+
console.log("Both are NOT EQUAL")
82+
}
83+
84+
// === operator
85+
a = 10;
86+
b = "10";
87+
if(a === b){
88+
console.log("Both are Equal");
89+
}
90+
else{
91+
console.log("Both are NOT EQUAL")
92+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
body{
2+
margin: 0;
3+
font-family: "Comic Sans MS",sans-serif;
4+
}
5+
h2{
6+
background-color: lightsalmon;
7+
text-align: center;
8+
padding: 10px;
9+
}
10+
div{
11+
background-color: orange;
12+
padding: 10px;
13+
text-align: center;
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS Conditional Statements</title>
6+
<link rel="stylesheet" href="08_styles.css">
7+
</head>
8+
<body>
9+
10+
<h2>JS Conditional Statements Example</h2>
11+
<div>
12+
<h1 id="display"></h1>
13+
</div>
14+
15+
<script src="08_script.js"></script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)