Random Quote machine, specific image with each quote via clicking a button HELP! lol


function getReason(){

var reasons = ["I honor you", "I respect you", "I appreciate you","I value you"];
var picture = ["https://farm5.staticflickr.com/4298/35798947220_cd638ef106_z.jpg","https://farm5.staticflickr.com/4300/35798947100_277c8f641d_z.jpg"];

var randomNum = Math.floor((Math.random()*reasons.length));
var randomReason = reasons[randomNum];
var randomPicture = picture[randomNum];



So my code isnt correct at all. My quotes are in a “div” element in a “span” element and the pictures are in a separate “span” element, located in the same “div” element


Your code looks fine, but I’m not sure why you want to show the URL as text in your element with class=picture. Maybe you can help us help you by sharing a codepen link? Without knowing what the HTML looks like, it’s hard to see what might be wrong.


i destroyed that code. I am not trying to show the url, i guess i dont know how to put my urls in so a picture will come up with each quote and not their url… thank you


You need an image tag. You’d need:

$(".picture").html('<img src="' + randomPicture + '">');

or something like that.