-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.html
64 lines (52 loc) · 1.59 KB
/
javascript.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>JavaScript</h1>
<p>javascript is a programming language</p>
<p id="demo"></p>
<p id="addstring"></p>
<p id="forloop"></p>
<p id="function"></p>
<p id="class"></p>
<p id="array"></p>
<script>
var x = 5;
var y = 6;
var z = x + y;
document.getElementById("demo").innerHTML =
"The value of z is: " + z;
let text1 = "John";
let text2 = "Doe";
let text3 = text1 + " " + text2;
document.getElementById("addstring").innerHTML = text3;
let text = "";
for (let i = 0; i < 5; i++) {
text += "The number is " + i + "<br>";
}
document.getElementById("forloop").innerHTML = text;
var x = myFunction(4, 3);
document.getElementById("function").innerHTML = x;
function myFunction(a, b) {
return a * b;
}
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
const myCar = new Car("Ford", 2014);
document.getElementById("class").innerHTML =
myCar.name + " " + myCar.year;
const cars = ["Saab", "Volvo", "BMW"];
document.getElementById("array").innerHTML = cars;
</script>
<button onclick="document.getElementById('event').innerHTML=Date()">The time is?</button>
<p id="event"></p>
</body>
</html>