-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
80 lines (66 loc) · 2.18 KB
/
index.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const pets = [
{
name: "Fido",
image: "images/pets/dog.jpeg",
description: "Fido the Dog. It wants to be your best friend!"
},
{
name: "Kitty",
image: "images/pets/cat.png",
description: "Kitty the Cat. It wants to be your cute baby kitten!"
},
{
name: "Hammy",
image: "images/pets/hamster.jpeg",
description: "Hammy the Hamster. It's so tiny and cute!"
},
{
name: "Polly",
image: "images/pets/parrot.jpeg",
description: "Polly the Parrot. Polly wants a cracker!"
},
{
name: "Angel",
image: "images/pets/horse.jpeg",
description: "Angel the Horse. It begs politely, like an angel, for you to adopt it."
},
{
name: "Fluffy",
image: "images/pets/guinea-pig.jpeg",
description: "Fluffy the Guinea Pig. It's so soft and fluffy!"
},
{
name: "Goldie",
image: "images/pets/fish.jpeg",
description: "Goldie the Goldfish. It lives under the sea and looks forward to sea you soon."
}
];
let draggedPet;
function displayPetDetails(pet){
const nameElement = document.querySelector('.name');
nameElement.textContent = pet.name;
const detailImageElement = document.querySelector('.detail-image');
detailImageElement.src = pet.image;
detailImageElement.alt = pet.name;
const descriptionDisplayElement = document.getElementById('description-display');
descriptionDisplayElement.textContent = pet.description;
}
displayPetDetails(pets[0]);
pets.forEach(addPetImageToPetsDiv);
function addPetImageToPetsDiv(pet){
const imgElement = document.createElement('img');
imgElement.src = pet.image;
imgElement.alt = pet.name;
const petsDiv = document.getElementById('pets');
petsDiv.appendChild(imgElement);
// Write your solution code for Task # 4 here!
}
function handleSubmit(event){
// Write your solution code for Task # 2 here!
}
function handleLoad(event){
// Write your solution code for Task # 3 here!
}
// Write your solution code for Task # 1 here!
// Write your solution code for Task # 5 here!
// Write your solution code for Task # 6 here!