forked from wesbos/es6.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfor-of-examples.html
50 lines (44 loc) · 1 KB
/
for-of-examples.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Iterables & Looping</title>
</head>
<body>
<p>Hi I'm p 01</p>
<p>Hi I'm p 02</p>
<p>Hi I'm p 03</p>
<p>Hi I'm p 04</p>
<p>Hi I'm p 05</p>
<p>Hi I'm p 06</p>
<p>Hi I'm p 07</p>
<p>Hi I'm p 08</p>
<p>Hi I'm p 09</p>
<p>Hi I'm p 10</p>
<script>
const cuts = ['Chuck', 'Brisket', 'Shank', 'Short Rib'];
// for (const [i, cut] of cuts.entries()) {
// console.log(`${cut} is the ${i + 1} item`);
// }
// function addUpNumbers() {
// let total = 0;
// for (const num of arguments) {
// total += num;
// }
// console.log(total);
// return total;
// }
// addUpNumbers(10,23,52,34,12,13,123);
// const name = 'Wes Bos';
// for (const char of name) {
// console.log(char);
// }
const ps = document.querySelectorAll('p');
for (const paragraph of ps) {
paragraph.addEventListener('click', function() {
console.log(this.textContent);
});
}
</script>
</body>
</html>