Code that rotates images in a set of divs I am rotating images inside some divs.

An image is associated with a link.Eg: image0 is associated with link0, image1 with link1 and so on.

image0 and link0 should display in pos-1  

image1/link1 and image2/link2 should rotate on page refresh in pos-2

image3/link3 and image4/link4 should rotate  on page refresh in pos-3  

Although currently I want to display only one image in pos-1, at a later stage I may rotate two images as well in pos-1. Similarly I may display only one image in pos-2. 

&lt;div id='pos-1'&gt;
&lt;/div&gt;
&lt;div id='pos-2'&gt;
&lt;/div&gt;
&lt;div id='pos-3'&gt;
&lt;/div&gt;

$(function(){
var image = new Array ();
  image[0] = "&lt;img src='https://placehold.it/200/09f/fff.png?text=image1'/&gt;&lt;/a&gt;";
  image[1] = "&lt;img src='https://placehold.it/200/000/fff.png?text=image2'/&gt;&lt;/a&gt;";
  image[2] = "&lt;img src='https://placehold.it/200/22f/000.png?text=image3'/&gt;&lt;/a&gt;";
  image[3] = "&lt;img src='https://placehold.it/200/32f/fff.png?text=image4'/&gt;&lt;/a&gt;";
  image[4] = "&lt;img src='https://placehold.it/200/42f/fff.png?text=image5'/&gt;&lt;/a&gt;";

var link = new Array ();
    link[0] = "&lt;a href='http://www.jquery.com'&gt;";
    link[1] = "&lt;a href='http://www.microsoft.com'&gt;";
    link[2] = "&lt;a href='http://www.yahoo.com'&gt;";
    link[3] = "&lt;a href='http://www.msn.com'&gt;";
    link[4] = "&lt;a href='http://www.stackoverflow.com'&gt;";

var min = 0;
var max = 1;
var x = Math.floor(Math.random() * (max - min) + min);
$('#pos-1').append(link[x]+image[x]);
min=1;
max=3;
x = Math.floor(Math.random() * (max - min) + min);
$('#pos-2').append(link[x]+image[x]);
min=3;
max=5;
x = Math.floor(Math.random() * (max - min) + min);
$('#pos-3').append(link[x]+image[x]);
  });


Please let me know if this code can be improved to perform better?
Demo: https://jsfiddle.net/y0hga2of/5/
The first thing I see in your code are the strings who represents an HTML element (in this case an img and an anchor element). 

This is a bad practice. Instead of appending a whole element to your HTML just update the src or href attribute.

The second thing I noticed is your implementation of a new array. Instead of using: 

var image = new Array ();
 image[0] = "&lt;img src='https://placehold.it/200/09f/fff.png?text=image1'/&gt;&lt;/a&gt;";


Use this approach:

var image = [
       "https://placehold.it/200/09f/fff.png?text=image1",
       "https://placehold.it/200/09f/fff.png?text=image2"
];


Also the naming of your variables is badly. The name:

 var image = new Array ();


and

var link = new Array ();


Suggests that they are holding exactly one image and one link. Actually they are  holding multiple links and images. Try to use names that describes what you can expect inside the variable. So use images and links instead.

Goodluck!

(Sorry for bad english, not a native speaker)