I'm trying to randomize value using javascript
but after trying for several hours I am failed continuously many time.
Here is the code which I am using.
<script type="text/javascript">
var banner1 = ["ca-pub-3060228829854466", "8550285936"];
var banner2 = ["ca-pub-3680851546903667", "4280702589"];
var allbanner = [banner1, banner2];
var banner = allbanner[Math.floor(Math.random() * allbanner.length)];
</script>
I have added two array banner[0]
and banner[1]
. when I am using in another JS
, it not calling the value's.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 336*280 -->
<ins class="adsbygoogle"
style="display:inline-block;width:336px;height:280px"
data-ad-client="banner[0]"
data-ad-slot="banner[1]"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Thanks for your help.