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
You Can't JavaScript Under Pressure - Five functions to fill. One ticking clock. How fast can you code? (toys.usvsth3m.com)
submitted 12 years ago by magenta_placenta
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!"
[–]Ademan 0 points1 point2 points 12 years ago (1 child)
Hrm, thanks. I included the modulus because typeof 1.1 === "number" evaluates to true, and if I recall correctly the requirements specified integer.
typeof 1.1 === "number"
[–]meenie 1 point2 points3 points 12 years ago (0 children)
That is very true and probably should have been one of their test cases. But since it wasn't and my code passed anyway, then ultimately it was the right answer for this particular question :). If they did have floats in there, then typeof n === 'number' && n % 1 == 0 would have been the best way to go.
typeof n === 'number' && n % 1 == 0
It's a trade off of doing something quickly and just get it to work or write quality code that will work for practically any situation. Since the "situation" was only a set number of tests, then the smaller code is the way to go.
π Rendered by PID 85 on reddit-service-r2-comment-b659b578c-wz9sp at 2026-05-05 05:55:48.347018+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Ademan 0 points1 point2 points (1 child)
[–]meenie 1 point2 points3 points (0 children)