0
java script %
How can i use that in real code?
2 Respostas
+ 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.
- 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.