

Show HN: A Repo of JavaScript Coding Challenges - kolodny
https://github.com/kolodny/exercises

======
dlo83
This looks great. Rebecca Murphy's JS Assessment is also a good resource for
testing your JavaScript chops:

[https://github.com/rmurphey/js-assessment](https://github.com/rmurphey/js-
assessment)

------
kevin
Man, I really hope people contribute to this. It would be great to see the
list of challenges with supposed difficulty level and expected amount of time
needed to finish.

Someone should make a repo for testing designer skills as well. Thanks for
sharing! This is really well done.

------
msoad
I'm interviewing for JS devs and trust me, none of ones I interviewed could
write a _.debounce function. Async throttle for promises?! If we find someone
who can understand the question she/he will be hired. They don't need to solve
it!

~~~
nialo
I'm looking for work as a programmer, and I think I understand the throttle
question and approximately what a solution would look like, although I would
need research to actually write one. Debounce sounds easy though. I'd love to
talk about your company and any opportunities you might have open, my email
address is bcoburn3@gmail.com

------
13years
Another great site of challenges can be found at
[http://codewars.com](http://codewars.com)

~~~
epmatsw
I like their interface a lot, but I'm not sure how I feel about the challenges
they actually have for JS. It seems like there's a lot of challenges that are
trivially solvable with Array.prototype.map, and then a bunch more that are
super complex and (for me at least) unsolvable. I wish there were more
challenges in the middle :(

------
rmrfrmrf
It's cool that these challenges are so functional programming oriented, but
I'd be a little bit concerned that the terminology might throw off some
otherwise-skilled web developers who aren't used to operating at such a
theoretical level. That problem would be compounded with definitions like "A
thunk is basically a function that you call with just the callback as a
parameter," in the challenge instructions (IMO that's a very layman definition
for such a technical question).

------
lewisl9029
HackerRank has a pretty good collection of multi-language challenges with a
range of difficulties and problem domains to choose from:

[https://www.hackerrank.com/](https://www.hackerrank.com/)

There's also a competitive aspect to it if you're into that kind of thing, but
I personally just use it as a casual learning/interview prep tool.

Their functional programming collection has been especially invaluable for me
for getting used to solving problems in a functional mindset.

------
BinaryIdiot
Hey those are pretty neat challenges! Personally I like tackling a project I'm
interested in that requires many of these aspects but these are pretty handy
if you want to quickly study or test a particular idea.

Edit: Glad to see an implementation of async.js in there as well; I feel like
writing your own version is practically a rite of passage in JavaScript.

------
kdamken
Looking on working on upping my JS skills in the near future. This will be
very helpful, thank you!

------
grumblestumble
This sucks, I still can't invert a binary tree!

~~~
ExpiredLink
Just google it.

------
madflame991
You can make an interesting challenge out any one of the bigger (in LOC)
functions of underscore.js or any promise library. You get a profound "a-ha"
moment the first time you implement `deepClone` or `Promise.all`

~~~
duaneb
I'm not super familiar with javascript, but are all copies shallow by default?
Deep copies are trivial enough to bake into the language.

~~~
rmrfrmrf
JavaScript objects are always pass reference by value (i.e. you're passing
around addresses copied by value which are then dereferenced when needed).
Copying objects _at all_ in JavaScript is therefore somewhat non-trivial,
especially if you need good performance. Typically, the most performant way to
deep-copy an object with an unknown structure is to do:

    
    
        var objCopy = JSON.parse(JSON.stringify(obj));
    

But that 1) is a rather disgusting hack and 2) can potentially break on
certain native JS Objects (like Date, for example). The most straightforward
way would be to use a for-in loop with a guard for Object.hasOwnProperty(),
but in practice, that's very slow by comparison.

~~~
madflame991
...and it gets even more interesting if you throw in a few circular references
in there

~~~
kolodny
[https://github.com/kolodny/jsan](https://github.com/kolodny/jsan) ;)

------
0xCA1C0DE5
Thanks for sharing. Does anyone have an extra copies of the Hack Reactor
challenges/lessons? Would love to brush up on my JS skills and I hear they're
the best.

------
reqres
Think there's an issue with the throttle challenge

For tests 3 and 4, you expect the context and args to be determined by the
last callback. But according to the first 2 tests, the last callbacks should
never be invoked.

Looks like someone already raised an issue:
[https://github.com/kolodny/exercises/issues/3](https://github.com/kolodny/exercises/issues/3)

------
danielvinson
Are these challenges supposed to be solvable within a reasonable amount of
time in an interview (15-30 minutes)? Looking through the problems they are
all things I could do, but I don't think I would be able to solve any of the
harder ones in under an hour - and that would be on my own, not in a high-
stress interview.

~~~
seanp2k2
Is solving a problem like this in 15-30 minutes under a good deal of stress
and likely without reference likely on a whiteboard something someone in the
position you're hiring for would ever need to do?

------
clintonc
I really like the approach of cloning the repository and writing to the tests!

------
echeese
In the throttle README, shouldn't throttled() be called instead of sayHi()?

~~~
kolodny
Yup, fixed. Thanks

------
amelius
Another nice task that fits in here is to convert an integer to a decimal
string and back. Obviously without using the native functions that do the
same.

Or to make a histogram of the letters that occur in some file.

------
phragg
Why would I edit index.js in vim vs test.js -- possible typo?

~~~
kolodny
You should be creating the index file, it's the solution to the problem. If
you were going to edit the test.js it would make it really simple ;)

~~~
phragg
ah gotcha :P tbh I'm not quite familiar with writing tests or making solutions
to tests, so these exercises will prove to be useful. Thanks!

------
xtrumanx
Pro tip: MDN is your friend while solving these.

