So after I've implemented the NativeAds, only 3 days after I've noticed that my random method of displaying the ad is stealing one item from the json.
So, currenlty I'm displaying the ads every 13 items
if (index % 13 == 0)
return adsContainer();
So this is stealing my 0 of json.
What could I do to stop this?
Solution 1: esqew
As you found out, 0 mod 13 == 0
. In fact, 0 mod
most all integers is 0
.
Why not just work around this by checking to make sure the index isn't 0
before checking if index % 13 == 0
?
if (index != 0 && index % 13 == 0) // make sure ad container is only displayed when we're not on index 0 and on every thirteenth element thereafter
return adsContainer();