I'm trying to make a very basic image slider. When the javascript code is in the same document with the html everything works fine but when I move the javascript to it's own folder and put link to the javascript in the header of the page it doesn't work. The pages have connected correctly. I will show code to make it more clear.


var imageSlider = document.getElementById('imageSlider');
var myPics = ['pic1.jpg, pic2.jpg, pic3.jpg'];
var totalPics = myPics.length;
var i = 0;
function loop() {
if(i > (totalPics - 1)){
i = 0;
imageSlider.innerHTML = '<img src="../images/slider/'+myPics[i]+'">';
loopTimer = setTimeout('loop()',3000);


<div id="pageContent">
<div id="imageSlider"></div>


Folders are set-up with html in root.
script in js folder.
images in images/slider/ folder.

Thanks in advance!