Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: A Repo of JavaScript Coding Challenges (github.com/kolodny)
127 points by kolodny on June 12, 2015 | hide | past | favorite | 31 comments



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

https://github.com/rmurphey/js-assessment


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.


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!


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


Are you hiring frontend JS devs or backend Node.js devs? If a backend dev doesn't understand the question and can't implement a basic debounce function then you are setting yourself up for a completely broken backend.

I've found that JS hiring in particular is very tricky because every frontend dev that has used a little jquery suddenly thinks they can create a server, which is completely inaccurate.

Interview questions like this can help you trim it down to the .5% who are actually capable Node.js devs.


I did an interview where they asked me exactly that. I got to a solution, but it took over a half hour which was too long and I wasn't hired. I barely understood closures at that time though! Today I could some thing like that so quick...


Another great site of challenges can be found at http://codewars.com


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 :(


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).


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/

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.


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.


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


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


Just google it.


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`


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


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.


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



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.


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


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.


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?


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


Yup, fixed. Thanks


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


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.


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


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 ;)


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!


Pro tip: MDN is your friend while solving these.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: