Underscore.js in challenges

Underscore.js in challenges


Hello fellow campers. I searched the forum, but couldn’t find anything useful about this. Is it possible to use underscore.js in challenges? It would make my life a lot easier in “Wherefore art thou” challenge if it were :slight_smile:
Thanks in advance.


I don’t think it’s possible. But it’s perfectly doable using just built-in functions.


I think the idea here on FCC is to help people develop their JavaScript Skills. Underscore.js is a library. While libraries are great tools to help developers, they are a collection of code that other developers have put together for you. It wouldn’t make sense to use a library to solve JavaScript challenges any more than it would make sense to do a math exam using other people’s answers. Unless of course there was a section specifically dedicated to Underscore, like there is for jQuery. If FCC allowed the use of Underscore.js, then it would have to allow all other JavaScript libraries, and god knows there are a gazillion of those. Why not start with learning the language?


Why not look at the annotated underscore.js docs for the functionality you want to use. If you don’t fully understand the code, you can always ask back here. That way you’ll deepen your understanding of javascript.


Thx, this really helped me. I don’t know why it didn’t occur to me, to go and check the docs. I was close to a solution before, but then I found underscore.js, and it looked really elegant and clean. Solved the challenge in just 4 lines of code. My current working solution is longer and complicated, but it works. Thanks again!


+1 on reading the annotated docs. I learned more about JS from the source code of Underscore, Backbone and CoffeeScript than anything else - the guy who wrote them, Jeremy Ashkenas, really tried to integrate literate programming into his JS stuff, so the code is designed as an essay that explains how it works. The annotated docs are built using another tool he wrote, Docco, which takes that code essay and visually splits the explanation from the code to make it easy to read. It’s a difficult thing to do well (and has the side effect of making programs very difficult to change once they’ve been written), so literate programming isn’t very common, but where it exists [I believe, ymmv] it’s exceptionally useful, particularly for tutorials - for example, the project sections of the book Eloquent JavaScript are examples of literate programming.

Literate Programming is an old (ancient) idea pioneered by Donald Knuth, who wrote a book with the same title. The idea is to write your source code as if it were an essay for a person to read, instead of a series of instructions for a machine to execute.

This involves trying to craft your code in a rhetorical style: introducing the big ideas, fleshing out the details in logical sections, referencing relevant portions…

(From here)