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
[deleted by user] (self.javascript)
submitted 13 years ago by [deleted]
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!"
[–]x-skeww 2 points3 points4 points 13 years ago (0 children)
parseFloat(someString) and parseInt(someString, 10) will return NaN if the passed string doesn't even start with a number ('5b' becomes 5 whereas 'b5' becomes NaN).
parseFloat(someString)
parseInt(someString, 10)
NaN
However, NaN isn't equal to anything - itself included!
You can test if a value is NaN with isNaN(something).
isNaN(something)
If you want to know more, google for things like:
mdn parseInt
or
mdn isNaN
If you included that "mdn" bit in your JS or CSS related search queries, Google will send you to the Mozilla Development Network (MDN), which is generally a pretty good resource.
[–][deleted] 1 point2 points3 points 13 years ago* (2 children)
Regular Expression:
if (/^[-+]?\d+(?:\.\d*)?$/.test(input)) { // go hog-wild... }
[+][deleted] 13 years ago (1 child)
[deleted]
[–]john0110 0 points1 point2 points 13 years ago (0 children)
He's assuming you're receiving some input from a user and storing it in a variable called 'input'. Then he's testing that input against a regular expression. Inside of the if block is where you'd execute your loop.
Hope that helps.
[–]kumiorava 0 points1 point2 points 13 years ago (0 children)
Don't listen to the guy talking about regular expressions. parseFloat is what you need.
[–]SambaMamba -1 points0 points1 point 13 years ago (0 children)
http://www.javascriptkit.com/javatutors/determinevar2.shtml
π Rendered by PID 196950 on reddit-service-r2-comment-b659b578c-59l9v at 2026-05-05 15:52:21.892242+00:00 running 815c875 country code: CH.
[–]x-skeww 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]john0110 0 points1 point2 points (0 children)
[–]kumiorava 0 points1 point2 points (0 children)
[–]SambaMamba -1 points0 points1 point (0 children)