-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript_1.html
More file actions
79 lines (65 loc) · 2.04 KB
/
Copy pathJavaScript_1.html
File metadata and controls
79 lines (65 loc) · 2.04 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
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Operators</h1>
<h2>The Assignment (=) Operator</h2>
<h3>JavaScript Expressions</h3>
<h4>Expressions Compute to Values</h4>
<h>Redeclaring a Variable Using var</h>
<p>The = operator is used to assign values to variables.</p>
<p>A JavaScript <b>program</b> is a list of <b>statements</b> to be executed by a computer.</p>
<p>Multiple statements on one line are allowed.</p>
<p>The underscore is treated as a letter in JavaScript names.</p>
<p>In this example, price1, price2, and total are variables.</p>
<p id="demo"></p>
<p id="demo1"></p>
<p id="demo2"></p>
<p id="demo3"></p>
<p id="demo4"></p>
<p id="demo5"></p>
<p id="demo*"></p>
<p id="demo_"></p>
<p id="demo#"></p>
<script>
let x = 5;
let y = 6;
let sum = x + y;
var xx
xx = 10
let a, b, c;
a = 4; b = 4; c = a + b;
let _x = 2;
let _100 = 5;
const price1 = 2;
const price2 = 1;
let total = price1 + price2;
var g = 10;
// Here x is 10
{
var g = 2;
// Here x is 2
}
document.getElementById("demo").innerHTML = "The sum is " + sum;
document.getElementById("demo1").innerHTML = 5 * 10;
document.getElementById("demo2").innerHTML = "John" + " " + "Doe";
document.getElementById("demo3").innerHTML = xx * 10;
document.getElementById("demo4").innerHTML = "The value of z is " + z;
</script>
</body>
</html>
<!-- Das Eingabefeld -->
<input type="text" id="nameInput" placeholder="Write your name here..." oninput="updateText()">
<!-- Hier erscheint das Ergebnis -->
<p id="demo">Hi there!</p>
<script>
function updateText() {
// 1. Wir holen uns den Wert aus dem Textfeld
let name = document.getElementById("nameInput").value;
// 2. Wir setzen diesen Wert in unseren Paragraphen ein
document.getElementById("demo").innerHTML = "Hi there, " + name + "!";
}
document.getElementById("demo5").innerHTML = c
document.getElementById("demo*").innerHTML = _x + _100
document.getElementById("demo_").innerHTML = "The total is: " + total
document.getElementById("demo").innerHTML = g;
</script>