Skip to content

Commit 4950a44

Browse files
committed
lesson 9
1 parent 4c68163 commit 4950a44

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>Console Tricks!</title>
7+
</head>
8+
9+
<body>
10+
11+
<p onClick="makeGreen()">×BREAK×DOWN×</p>
12+
13+
<script>
14+
const dogs = [{ name: 'Snickers', age: 2 }, { name: 'hugo', age: 8 }];
15+
16+
function makeGreen() {
17+
const p = document.querySelector('p');
18+
p.style.color = '#BADA55';
19+
p.style.fontSize = '50px';
20+
}
21+
22+
// Regular
23+
console.log('hello');
24+
25+
// Interpolated
26+
console.log('Hello I am a %s string!', 'asdf');
27+
28+
// Styled
29+
console.log('%c I am some great text', 'font-size:50px; background:red; text-shadow: 10px 10px 0 blue');
30+
31+
// warning!
32+
console.warn('OH NOOO');
33+
34+
// Error :|
35+
console.error('OOPS!');
36+
37+
// Info
38+
console.info('Crocodiles eat 3-4 people per year');
39+
40+
// Testing
41+
const p = document.querySelector('p');
42+
43+
console.assert(p.classList.contains('ouch'), 'That is wrong!');
44+
45+
// clearing
46+
console.clear();
47+
48+
// Viewing DOM Elements
49+
console.log(p); // element itself
50+
console.dir(p); // all the attributes/functions on the element - see __proto__ for functions
51+
52+
console.clear();
53+
54+
// Grouping together
55+
dogs.forEach(dog => {
56+
console.groupCollapsed(`${dog.name}`);
57+
console.log(`This is ${dog.name}`);
58+
console.log(`${dog.name} is ${dog.age * 7} dog years old`);
59+
console.groupEnd(`${dog.name}`);
60+
});
61+
62+
// counting
63+
console.count('Bryan');
64+
console.count('Bryan');
65+
console.count('Bryan');
66+
console.count('Wes');
67+
console.count('Bryan');
68+
console.count('Wes');
69+
console.count('Bryan');
70+
71+
// timing
72+
console.time('fetching data');
73+
fetch('https://api.github.com/users/bhutchinson')
74+
.then(data => data.json())
75+
.then(data => {
76+
console.timeEnd('fetching data');
77+
console.log(data);
78+
});
79+
80+
// table
81+
console.table(dogs);
82+
83+
</script>
84+
</body>
85+
86+
</html>

0 commit comments

Comments
 (0)