-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (46 loc) · 1.38 KB
/
app.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
const team = [
{
name: 'Tanya Sinclair',
sentence: ` “ I’ve been interested in coding for a while but never taken the jump, until now.
I couldn’t recommend this course enough. I’m now in the job of my dreams and so
excited about the future. ”`,
position: 'UX Engineer',
img: './images/image-tanya.jpg',
},
{
name: 'John Tarkpor',
sentence: ` “ If you want to lay the best foundation possible I’d recommend taking this course.
The depth the instructors go into is incredible. I now feel so confident about
starting up as a professional developer. ”`,
position: 'Junior Front-end Developer',
img: './images/image-john.jpg',
},
];
let Item = 0;
const sentence = document.getElementById('sentence');
const name = document.getElementById('name');
const position = document.getElementById('position');
const img = document.getElementById('avatar');
const prev = document.getElementById('prev');
const next = document.getElementById('next');
function showPerson(num){
const person = team[num];
img.src = person.img;
name.textContent = person.name;
position.textContent = person.position;
sentence.textContent = person.sentence;
}
prev.addEventListener('click', () => {
Item--;
if (Item < 0) {
Item = team.length - 1;
}
showPerson(Item);
});
next.addEventListener('click', () => {
Item++;
if (Item >= team.length) {
Item = 0;
}
showPerson(Item);
});