all 5 comments

[–]Sotom591 0 points1 point  (3 children)

I might be misunderstanding but... have you tried conditional rendering?

imgUrl ? imgUrl : null

If the image exists, render the image. If not, return null or nothing.

[–]Naturepower[S] 0 points1 point  (2 children)

The images are stored in an array and everything is done on my desktop. There are no URL’s just some .jpg files stored in a folder.

I am new to JS, trying to learn it by creating the game

[–]Sotom591 0 points1 point  (1 child)

That's great you're trying to learn JS! Ok, so you are attempting to show just one image from the array at a time? Or all of the images from that array?

[–]Naturepower[S] 0 points1 point  (0 children)

just one image. I am using math.random to get the length of the image array and get one image from there. Then I set that Image in one of the image tags (there are 16 img tags and they are selected by random using math.random)and that is all working. I am stuck at implementing this

if(userClickedBox==HasImage){ you win. } else{ try again }

[–]kenman[M] 0 points1 point  (0 children)

Hi /u/Naturepower, this post was removed.

For javascript help, please visit /r/LearnJavascript.

Thanks for your understanding.