-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass13.html
More file actions
118 lines (116 loc) · 3.31 KB
/
class13.html
File metadata and controls
118 lines (116 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Class 13</title>
</head>
<body>
<script>
// Global scope: accessed anywhere in program
var var1="Lily"
let let1="Bobby"
const const1="City"
// difference between var and let
//let can be acessed only inside block scope
//const can't be redeclared or reassigned
// Functional scope: Accesed only inside a function
function Data()
{
var a=10
let b=20
const c=30
console.log(a)
//block scope:only var can be acessed outside
if(30>20)
{
let e="End task"
var f="Function"
const pi=3.14
console.log(pi)
}
//comparison
var comp=a
console.log(2==2)
console.log(2==="2")
//array
//homogeneous
var myarray=["Data","Details","Status"]
//heterogenous-> different datatypes
var array2=["da",1,746378.4,true]
console.log(myarray)
console.log(array2)
//Index Number-> PRINTING individual data
console.log(myarray[0])
console.log(array2[0])
}
Data()
// console.log(let1)
//= assignment
//==compare
//===compare value and data type
if(5>10)
{
console.log("The data is correct")
}
else{
console.log("The data is incorrect")
}
var username=prompt("Enter the user ")
var password=prompt("Enter the pass")
if(username=="admin" && password=="pass")
{
console.log("You are logged in")
}
else{
console.log("Enter the correct credentials")
}
// for loop
for(i=0;i<10;i++)
{
console.log("The value of count is"+i)
}
function fizzBuzz()
{
for(let i=1;i<=10;i++)
{
if(i%3==0)
{
console.log('Fizz')
if(i%5==0)
{
console.log('Buzz')
}
if(i%3==0 && i%5==0)
{
console.log('FizzBuzz')
}
}
else
{
console.log(i)
}
}
}
fizzBuzz()
// OBJECT :consist of key and value
let object1={
Brand:"Asus",
Model:2163,
RAM:"128GB",
color:"white"
}
console.log(object1)
console.log(object1.Brand)
</script>
</body>
</html>
<!-- DOM :Document Object Model is an API for HTML and XML -->
<!-- DOM Selectors:select HTML elements within a document using javascript -->
<!-- 5 ways -->
<!-- 1.getElementsByTagName()
2.getElementsByClassName()
3.getElementsById()
4.querySelector()
5.querySelectorAll() -->