X Tutup
Skip to content

Commit 2ace69b

Browse files
committed
beginner JS
1 parent c6eef3f commit 2ace69b

File tree

19 files changed

+2543
-1
lines changed

19 files changed

+2543
-1
lines changed

.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"wesbos"
4+
]
5+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const people = [
2+
{ name: 'Wes', cool: true, country: 'Canada' },
3+
{ name: 'Scott', cool: true, country: 'Merica' },
4+
{ name: 'Snickers', cool: false, country: 'Dog Country' },
5+
];
6+
7+
/* Victor Mono */
8+
// New Font!
9+
people.forEach((person, index) => {
10+
console.log(person.name);
11+
});
12+
13+
// console.table(people);
14+
15+
// Console Methods
16+
17+
// Callstack, Stack Trace
18+
19+
// Grabbing Elements
20+
21+
// Breakpoints
22+
23+
// Scope
24+
25+
// Network Requests
26+
27+
// Break On Attribute
28+
29+
// Some Setup Code
30+
31+
function doALotOfStuff() {
32+
console.group('Doing some stuff');
33+
console.log('Hey Im one');
34+
console.warn('watch out!');
35+
console.error('hey');
36+
console.groupEnd('Doing some stuff');
37+
}
38+
39+
function doctorize(name) {
40+
// console.count(`running Doctorize for ${name}`);
41+
return `Dr. ${name}`;
42+
}
43+
44+
function greet(name) {
45+
doesntExist(); // Cause an error
46+
return `Hello ${name}`;
47+
}
48+
49+
function go() {
50+
const name = doctorize(greet('Wes'));
51+
console.log(name);
52+
}
53+
54+
function bootstrap() {
55+
console.log('Starting the app!');
56+
go();
57+
}
58+
59+
// bootstrap();
60+
61+
const button = document.querySelector('.bigger');
62+
button.addEventListener('click', function(e) {
63+
const newFontSize =
64+
parseFloat(getComputedStyle(e.currentTarget).fontSize) + 1;
65+
e.currentTarget.style.fontSize = `${newFontSize}px`;
66+
});
67+
68+
// A Dad joke fetch
69+
async function fetchDadJoke() {
70+
const res = await fetch('https://icanhazdadjoke.com/', {
71+
headers: {
72+
Accept: 'text/plain',
73+
},
74+
});
75+
const joke = await res.text();
76+
console.log(joke);
77+
return joke;
78+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const people = [
2+
{ name: 'Wes', cool: true, country: 'Canada' },
3+
{ name: 'Scott', cool: true, country: 'Merica' },
4+
{ name: 'Snickers', cool: false, country: 'Dog Country' },
5+
];
6+
7+
people.forEach((person, index) => {
8+
console.log(person.name);
9+
});
10+
11+
// Console Methods
12+
13+
// Callstack
14+
15+
// Grabbing Elements
16+
17+
// Breakpoints
18+
19+
// Scope
20+
21+
// Network Requests
22+
23+
// Break On Attribute
24+
25+
// Some Setup Code
26+
27+
function doctorize(name) {
28+
return `Dr. ${name}`;
29+
}
30+
31+
function greet(name) {
32+
doesntExist();
33+
return `Hello ${name}`;
34+
}
35+
36+
function go() {
37+
const name = doctorize(greet('Wes'));
38+
console.log(name);
39+
}
40+
41+
const button = document.querySelector('.bigger');
42+
button.addEventListener('click', function(e) {
43+
const newFontSize =
44+
parseFloat(getComputedStyle(e.currentTarget).fontSize) + 1;
45+
e.currentTarget.style.fontSize = `${newFontSize}px`;
46+
});
47+
48+
// A Dad joke fetch
49+
async function fetchDadJoke() {
50+
const res = await fetch('https://icanhazdadjoke.com/', {
51+
headers: {
52+
Accept: 'text/plain',
53+
},
54+
});
55+
const joke = await res.text();
56+
console.log(joke);
57+
return joke;
58+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title></title>
8+
<link rel="stylesheet" href="../../base.css">
9+
</head>
10+
11+
<body>
12+
<button class="bigger">Make Me Bigger</button>
13+
<script src="./debugging.js"></script>
14+
</body>
15+
16+
</html>

0 commit comments

Comments
 (0)
X Tutup