-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslideshowChallenge.js
More file actions
32 lines (32 loc) · 924 Bytes
/
slideshowChallenge.js
File metadata and controls
32 lines (32 loc) · 924 Bytes
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
var slideshow = {
photoList: ["beach","ball", "tree", "train"],
currentPhotoindex: 0,
nextPhoto: function() {
this.currentPhotoindex++;
if(this.currentPhotoindex < this.photoList.length) {
console.log(this.photoList[this.currentPhotoindex], this.currentPhotoindex);
} else {
console.log("end of slideshow.");
}
},
prevPhoto: function() {
this.currentPhotoindex--;
if(this.currentPhotoindex >= 0) {
console.log(this.photoList[this.currentPhotoindex], this.currentPhotoindex);
} else {
console.log("beginning of slideshow.");
}
},
getCurrentPhoto: function() {
return console.log(this.photoList[this.currentPhotoindex]);
}
}
slideshow.nextPhoto();
slideshow.nextPhoto();
slideshow.nextPhoto();
slideshow.getCurrentPhoto();
slideshow.getCurrentPhoto();
slideshow.prevPhoto();
slideshow.prevPhoto();
slideshow.prevPhoto();
slideshow.getCurrentPhoto();