I have a for loop that is iterating through some data. Every 10th iteration I need to display an ad from Google Adsense.
However, when I insert the Adsense code the rest of my code breaks -- I get an "Unexpected EOF."
Here is what I have, based off of this example from Google:
for (var i = 0; i < json.length; i++) {
if ((i % 10) == 0)$("#contentRow").append(`
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
<ins class="adsbygoogle" style="display:block"
data-ad-format="fluid"
data-ad-client="ca-pub-1234567891234567"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
`);
$("#contentRow").append(`-- iterating my data here... --`)
This all works fine until I add the Adsense code. Replacing the Adsense code with hello world, for example, works just fine. But once the Adsense code is included everything breaks, think because of the script tags. Any help?