0

java script %

How can i use that in real code?

31st Mar 2017, 1:10 PM
prof itin (trade)
prof itin (trade) - avatar
2 Answers
+ 4
Suppose you have to create an image slider. You have an image array as var imageArr = ["img1","img2","img3"] Now you have a variable currIndex as var currIndex = 0; Now, you have a button show next, this should increment currIndex but should also be in the limits of the imageArr so you will write like currIndex = (currIndex+1)%imageArr.length Hope, this helps.
31st Mar 2017, 1:21 PM
Ashwani Kumar
Ashwani Kumar - avatar
- 1
% - get module (fission residue) 7 % 2 // result 1 8 % 2 // result 0 For example. You can check whether the number is even or odd.
31st Mar 2017, 1:21 PM
Andrey