-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
119 lines (102 loc) · 2.92 KB
/
test.html
File metadata and controls
119 lines (102 loc) · 2.92 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>
<style>
</style>
<script>
console.log("Hello World!");
// operations
console.log(2 + 2);
console.log("Hello " + "World");
console.log("Hello " + 2);
console.log(5 - 2);
// variables
x = 8;
console.log(x);
var y = 10;
console.log(10);
var j = "hello";
j = 3;
j = 1.432;
console.log(j);
y++;
console.log(y);
var bleh = "hello";
console.log(bleh[0]);
// conditionals
if (x > 30)
{
console.log("I'm in the conditional");
}
else if(x < 20)
{
console.log(`${x} is less than 20`);
}
else
{
console.log("that else statement");
}
switch(y)
{
case 11:
console.log("eleven!");
break;
case 12:
console.log("twelve!");
break;
default:
console.log("Not 11 or 12");
}
// functions
// the old way
function someFunction() {
console.log("hello from a function!");
return "Hello!";
}
someFunction();
// the other old way
anotherFunction = function () {
console.log("this is another function");
}
// new way ES6
newFunction = () => {
console.log("This is the ES 6 way!");
}
// but why tho
var z = 5;
z = () => {
console.log("OH man, what happened to z?");
}
z();
// function with parameters
addTogether = (x, y) => {
console.log(x + y);
}
addTogether(10, 12);
addTogether(x, y); // remember these were 8 and 11
x = "apple";
y = "banana";
addTogether(x, y);
// function with parameters that are functions
runMe = (h) => {
h();
}
// runMe in the old style
function runMe2 (h) {
h();
}
// loops
// arrays
// classes/objects
copyToDiv = () => {
var text = document.getElementById("stuff").value
document.getElementById("otherStuff").innerHTML = text;
}
</script>
</head>
<body>
<button onClick="copyToDiv()">Click me!</button>
<input type="text" id="stuff" />
<div id="otherStuff">Hi!</div>
</body>
</html>