Skip to content

Commit d1d16a9

Browse files
committed
some more exercices
1 parent f2953bc commit d1d16a9

File tree

5 files changed

+50
-1
lines changed

5 files changed

+50
-1
lines changed

exercises/20 - The DOM/creating.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const list = document.createElement('ul');
2+
3+
const thirdElement = document.createElement('li');
4+
thirdElement.textContent = 'Troisième élément';
5+
list.appendChild(thirdElement);
6+
7+
const secondElement = document.createElement('li');
8+
secondElement.textContent = 'Second élément';
9+
list.insertAdjacentElement('afterbegin', secondElement);
10+
document.body.appendChild(list);

exercises/20 - The DOM/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<body>
1212
<div class="items">
13+
<p class="item" id="me">C'est moi</p>
1314
<p>Hi I'm a item</p>
1415
<div>
1516
<h2>Sub Div</h2>
@@ -20,6 +21,7 @@ <h2>Sub Div</h2>
2021
<p>Hi I'm a item</p>
2122
<p>Hi I'm a item</p>
2223
</div>
24+
<script src="./creating.js"></script>
2325
</body>
2426

2527
</html>

playground/closures.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,43 @@
99
</head>
1010

1111
<body>
12+
<script>
13+
// function outer() {
14+
// const outerVar = 'This is the outer var';
15+
// function inner() {
16+
// const innerVar = 'I am the inner var';
17+
// console.log(innerVar);
18+
// console.log(outerVar);
19+
// }
20+
// return inner;
21+
// }
22+
// const innerFn = outer();
23+
// innerFn();
1224

25+
// function createGreeting(greeting = '') {
26+
// const myGreet = greeting.toUpperCase();
27+
// return function (name) {
28+
// return `${myGreet} ${name}`;
29+
// };
30+
// }
31+
32+
// const sayHello = createGreeting('hello');
33+
// const sayHey = createGreeting('hey');
34+
// console.log(sayHello('wes'));
35+
// console.log(sayHello('kait'));
36+
// console.log(sayHey('kait'));
37+
38+
function createGame(gameName) {
39+
let score = 0;
40+
return function win() {
41+
score++;
42+
return `Your game ${gameName} score is ${score}`;
43+
};
44+
}
45+
46+
const pinballGame = createGame('Pinball');
47+
const witcherGame = createGame('Witcher');
48+
</script>
1349
</body>
1450

1551
</html>

playground/hoisting.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</head>
1010

1111
<body>
12-
12+
<script src="./hoisting.js"></script>
1313
</body>
1414

1515
</html>

playground/hoisting.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('hey');

0 commit comments

Comments
 (0)