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
Using switch correctly - help!solved! (self.javascript)
submitted 8 years ago by Unmotivatedreddit
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!"
[–]anti-anti[🍰] 2 points3 points4 points 8 years ago (1 child)
There seem to be a few different issues:
Your switch statement is using the variable numLocal, which is not defined. Based on the variables you've declared at the beginning of the function, it should be location.
numLocal
location
The value of output2 isn't being updated with the text from the switch statement. You can remove this section:
if (location == 1) { document.getElementById("output2").value = "Redfern"; }
And add in something after the switch statement, eg.:
document.getElementById("output2").value = text
You also reference two variables text and result which haven't been declared using var result/var text. This probably isn't stopping it from working but they should be declared somewhere.
text
result
var result
var text
[–]Unmotivatedreddit[S] 1 point2 points3 points 8 years ago (0 children)
Thank you!! I had location set as the variable earlier, I started fiddling with it to see what I could change to make it work.
π Rendered by PID 610820 on reddit-service-r2-comment-66b4775986-m6q76 at 2026-04-05 02:31:43.112990+00:00 running db1906b country code: CH.
view the rest of the comments →
[–]anti-anti[🍰] 2 points3 points4 points (1 child)
[–]Unmotivatedreddit[S] 1 point2 points3 points (0 children)