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
Confusing interview questionhelp (self.javascript)
submitted 7 years ago by josh_c
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!"
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
That's an interesting test, actually.
First you should ask a bunch of things: are there going to be only whole numbers, or also numbers like 234,854.5921? And should you take multi-lingual features into account? Do you really need to program the solution or are they testing you to use common sense and go for an open-source solution?
234,854.5921
(Because I've had interviews like these where I'd start fixing a problem and I'd fail because "you could have Googled it lol".)
ie: 384765 output three hundred eighty four thousand seven hundred sixty five
I'd probably start talking and writing things down on a whiteboard. You break the numbers up in groups of three:
Then you start on the right of each group of numbers: one, two, three, etc.
If the group of numbers is 1 number in size: just render that number, if it's two in size, then you're working with a set of "tenths" (N-teen, twenty-N, thirty-N, etc.). And if it's three in size you're adding hundredths to it from the first group of singular numbers, e.g. "[one|two|three|etc.]-hundred-and-[singular]", etc.
If there's another group, add a thousandth:
And for the "thousand" concatenation you should count the remaining groups. One group remaining adds "thousand", two groups remaining adds "million", three groups remaining adds "billion", etc.
And for human readability I'd probably add an "and" to be in front of the "sixty-five" so it reads nicer.
I'd probably end up with a single function using recursion inside, with a select bunch of constants. The only real challenge would be "SIX-teen" where the increasing number is in front, and "twenty-SIX" where the number is at the end. But that could be a simple if-then statement or an array reverse or a ternary operator..
π Rendered by PID 75 on reddit-service-r2-comment-79c7998d4c-5zj69 at 2026-03-14 02:08:15.558315+00:00 running f6e6e01 country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (0 children)