<script type="text/javascript">
//Javascript Created by Computerhope https://www.computerhope.com/
//store the quotations in arrays
var images = [],
index = 0;
images[0] = "<a href = 'https://www.computerhope.com/'><img src='https://www.computerhope.com/banners/banner.gif' alt='Visit Computer Hope'></a>";
images[1] = "<a href = 'https://www.computerhope.com/history'><img src='https://www.computerhope.com/banners/banner2.gif' alt='Computer History'></a>";
images[2] = "<a href = 'https://www.computerhope.com/'><img src='https://www.computerhope.com/banners/banner3.gif' alt='Visit Computer Hope'></a>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
//done
</script>
//Data
let memesData= {
"success": true,
"data": {
"memes": [
{
"id": "181913649",
"name": "Drake Hotline Bling",
"url": "https://i.imgflip.com/30b1gx.jpg",
"width": 1200,
"height": 1200,
"box_count": 2
},
{
"id": "87743020",
"name": "Two Buttons",
"url": "https://i.imgflip.com/1g8my4.jpg",
"width": 600,
"height": 908,
"box_count": 3
},
{
"id": "112126428",
"name": "Distracted Boyfriend",
"url": "https://i.imgflip.com/1ur9b0.jpg",
"width": 1200,
"height": 800,
"box_count": 3
},
{
"id": "131087935",
"name": "Running Away Balloon",
"url": "https://i.imgflip.com/261o3j.jpg",
"width": 761,
"height": 1024,
"box_count": 5
},
{
"id": "247375501",
"name": "Buff Doge vs. Cheems",
"url": "https://i.imgflip.com/43a45p.png",
"width": 937,
"height": 720,
"box_count": 4
},
{
"id": "129242436",
"name": "Change My Mind",
"url": "https://i.imgflip.com/24y43o.jpg",
"width": 482,
"height": 361,
"box_count": 2
},
{
"id": "124822590",
"name": "Left Exit 12 Off Ramp",
"url": "https://i.imgflip.com/22bdq6.jpg",
"width": 804,
"height": 767,
"box_count": 3
}
]
}
}
//Extracting images only from the data in an array
let varr=[]
let memeimg = memesData.data.memes.map(x =>{
varr.push(x.url)
})
// Using some math.random function and we are good to go
let randomImgGenerator=(params)=>{
return params[Math.floor(Math.random()*params.length)]
}
console.log(randomImgGenerator(varr))