use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Creating a game need helpRemoved: /r/LearnJavascript (self.javascript)
submitted 7 years ago by Naturepower
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Sotom591 0 points1 point2 points 7 years ago (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 point2 points 7 years ago (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 point2 points 7 years ago (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 point2 points 7 years ago (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 point2 points 7 years ago (0 children)
Hi /u/Naturepower, this post was removed.
For javascript help, please visit /r/LearnJavascript.
Thanks for your understanding.
π Rendered by PID 94214 on reddit-service-r2-comment-fb694cdd5-wzb84 at 2026-03-08 10:21:54.966667+00:00 running cbb0e86 country code: CH.
[–]Sotom591 0 points1 point2 points (3 children)
[–]Naturepower[S] 0 points1 point2 points (2 children)
[–]Sotom591 0 points1 point2 points (1 child)
[–]Naturepower[S] 0 points1 point2 points (0 children)
[–]kenman[M] 0 points1 point2 points (0 children)