5 ms·
Show HN: A Repo of JavaScript Coding Challenges
- echeese 11y agoIn the throttle README, shouldn't throttled() be called instead of sayHi()?
- kolodny 11y agoYup, fixed. Thanks
- 0xCA1C0DE5 11y agoThanks 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.
- phragg 11y agoWhy would I edit index.js in vim vs test.js -- possible typo?
- kolodny 11y agoYou 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 11y agoah 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!
- msoad 11y agoI'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!
- savanaly 11y agoI 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...
- nialo 11y agoI'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
- NathanKP 11y agoAre 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.
- kdamken 11y agoLooking on working on upping my JS skills in the near future. This will be very helpful, thank you!
- madflame991 11y agoYou 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 11y agoI'm not super familiar with javascript, but are all copies shallow by default? Deep copies are trivial enough to bake into the language.
- rmrfrmrf 11y agoJavaScript 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 11y ago...and it gets even more interesting if you throw in a few circular references in there
- kolodny 11y agohttps://github.com/kolodny/jsan https://github.com/kolodny/jsan ;)
- 13years 11y agoAnother great site of challenges can be found at http://codewars.com http://codewars.com
- epmatsw 11y agoI 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 :(
- BinaryIdiot 11y agoHey 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.
- rmrfrmrf 11y agoIt'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).
- dlo83 11y agoThis 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
- xtrumanx 11y agoPro tip: MDN is your friend while solving these.
- reqres 11y agoThink 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 11y agoAre 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 11y agoIs 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?
- amelius 11y agoAnother 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.
- kevin 11y agoMan, 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.
- grumblestumble 11y agoThis sucks, I still can't invert a binary tree!
- ExpiredLink 11y agoJust google it.
- lewisl9029 11y agoHackerRank 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.
- clintonc 11y agoI really like the approach of cloning the repository and writing to the tests!