Random img not working

Random img not working
0.0 0

#1

Tell us what’s happening:

//html code//
<div class="products">
			
			<div class="product">
				<img id="myimg" src="images/cover.jpg" alt="product"><!--image save as from googel-->
				<div>More info</div>
			</div>

//js code//
 myElement=document.getElementById('myimg');
  
  myimgs['images/cover.jpg','images/download.jpg']
  
  function changeImg(myElement,myimgs){
	 var myRondomNum=Math.floor(Math.random()* myimgs.length);
	 setInterval(function(){
	 myElement.src=myimgs[myRondomNum];	  
     },1000);
 }
	 changeImg(myElement,myimgs);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36.

Link to the challenge:


#2

You asked for help on the Factorial challenge, but your code has nothing to do with that challenge. Also, you have not explained what you are trying to accomplish with the code and what it is doing instead.


#3

hi,thank you for replying,I wanted to change img from html by id 'myimg’to to random img in every time the page reloaded from myimgs array .Thank you


#4

Hi Randell,thank you the problem solved,