-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdogs.js
43 lines (40 loc) · 1.04 KB
/
dogs.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
import { dogs } from "./data.js"
class Dog {
constructor(data) {
Object.assign(this, data)
}
getDogHtml() {
const { name, age, avatar, bio} = this
return `
<img class="dog-picture" src=${avatar}>
<div class="text-box">
<h2 class="profile-data">${name}, ${age}</h2>
<h3 class="profile-bio">${bio}</h3>
</div>
`
}
likedDog(dogId) {
dogs.forEach( dog => {
if(dog.name === dogId.name) {
dog.hasBeenLiked = true
}
})
}
swipedDog(dogId) {
dogs.forEach( dog => {
if(dog.name === dogId.name) {
dog.hasBeenSwiped = true
}
})
}
getNewDogArray() {
let newDogArray = []
dogs.forEach( dog => {
if(!dog.hasBeenLiked && !dog.hasBeenSwiped) {
newDogArray.push(dog)
}
})
return newDogArray
}
}
export default Dog