Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit faad510

Browse files
committed
JS exercises done
1 parent be2a1ad commit faad510

File tree

6 files changed

+78
-2
lines changed

6 files changed

+78
-2
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
//Changing Font
12
document.body.style.fontFamily = "Arial,sans-serif";
3+
//Adding personal info
24
document.querySelector("#nickname").innerHTML = "Stef";
35
document.querySelector("#fav-food").innerHTML = "Pastitsio";
46
document.querySelector("#hometown").innerHTML = "New Philadelphia";
5-
7+
//Adding class in each li inside the ul
68
let listItem = document.getElementsByTagName("li");
79
for (let i = 0; i < listItem.length; i++) {
810
listItem[i].className = "list-item"
9-
}
11+
}
12+
//Adding Photo
13+
let myPhoto = document.createElement("img");
14+
myPhoto.src = "https://media-exp1.licdn.com/dms/image/C5603AQH-4xn8lqwm_A/profile-displayphoto-shrink_200_200/0?e=1586390400&v=beta&t=cdHKfe_B5JDWPC76dV4BqGO1uUhKCzQk6ISv99lTYcY";
15+
document.body.appendChild(myPhoto);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Cat Walk</title>
7+
</head>
8+
9+
<body>
10+
<img style="position:absolute;" src="http://www.anniemation.com/clip_art/images/cat-walk.gif" />
11+
<script src="catWalk.js"></script>
12+
</body>
13+
14+
</html>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict'
2+
let catImage = document.querySelector("img");
3+
let positionNum = 10
4+
let positionStyle = catImage.style.left = positionNum + "px";
5+
let screenWidth = window.innerWidth;
6+
7+
setInterval(function () {
8+
positionNum += 10;
9+
catImage.style.left = positionNum + "px";
10+
if (positionNum === screenWidth / 2) {
11+
catImage.src = "https://media1.tenor.com/images/2de63e950fb254920054f9bd081e8157/tenor.gif?itemid=10561424";
12+
}
13+
else if (positionNum === screenWidth) {
14+
positionNum = 10;
15+
catImage.src = "http://www.anniemation.com/clip_art/images/cat-walk.gif"
16+
}
17+
18+
}, 60)
19+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use strict"
2+
function hijackGoogleLogo() {
3+
let oldLogo = document.getElementById("hplogo");
4+
oldLogo.src = "https://www.hackyourfuture.dk/static/logo-dark.svg";
5+
oldLogo.srcset = "https://www.hackyourfuture.dk/static/logo-dark.svg";
6+
}
7+
hijackGoogleLogo();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict"
2+
//Create an h1 that contains the time
3+
let h1 = document.createElement("h1");
4+
h1.style.fontSize = ("5rem");
5+
h1.style.textAlign = ("center");
6+
document.body.appendChild(h1);
7+
8+
//Function to show the current time
9+
function currentTime() {
10+
setInterval(function () {
11+
let today = new Date();
12+
let time = `${today.getHours()}:${today.getMinutes()}:${today.getSeconds()}`;
13+
h1.innerHTML = time;
14+
}, 1000);
15+
}
16+
//Function onload
17+
h1.onload = currentTime();
18+
19+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
3+
<head>
4+
<title>Current time</title>
5+
</head>
6+
7+
<body>
8+
<script src="showCurrentTime.js"></script>
9+
</body>
10+
11+
</html>

0 commit comments

Comments
 (0)