I've asked this question already but I haven't been able to get many answers. I'll try and be more clear with this one!
I have an array which I am randomizing using math.random. I am displaying this array in the browser, each time the page refreshes it randomizes and outputs a different array item. Each array item contains a title and description which works, but I am also trying to add an image. I want this image to be displayed in the browser.
JavaScript:
var myArray = [
{title: "my title", description: "my description", image: "file path"},
];
function getArray(ary){
return ary[Math.floor(Math.random()*ary.length)];
}
var random = getArray(action);
and then in my HTML I have a <script>
tag to display each portion of the item to the browser,
document.write(random.title);
document.write(random.description);
document.write(random.image);
The problem is, the image doesn't show up it only displays the actual file path in text. How am I able to display the actual image?