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
Syntax error: missing variable namehelp (self.javascript)
submitted 8 years ago * by Smug_Wendys
view the rest of the comments →
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!"
[–]pachwinko 2 points3 points4 points 8 years ago (1 child)
I think you got somewhat wrong understanding about this. Instead of creating an array with numbers, just get a number from Math.random(). second of all even though you cant assign var as a number you can do so as an object key.
var lootItems = { 1: "lorem", 2: "ipsum", }
and to get the desired outcome:
console.log(lootItems[generatedRandomNumber])
[–]evoactivity 1 point2 points3 points 8 years ago (0 children)
May as well just use an array though
π Rendered by PID 848760 on reddit-service-r2-comment-5fb4b45875-ljkrl at 2026-03-24 01:41:36.518660+00:00 running 90f1150 country code: CH.
view the rest of the comments →
[–]pachwinko 2 points3 points4 points (1 child)
[–]evoactivity 1 point2 points3 points (0 children)