I’m steadily working through the bonfires and projects and at first I was just happy when I got stuff to work. Now I’m more critical of my knowledge and code.
How can I go from those twenty line functions to the one or two line functions that do the exact same thing? IE tutorials. books, courses etc…
Or does it not even matter, as long as it works it works?
As you understand JS and programatic problem solving better, you might enjoy going back to earlier challenges and doing them again. (This is called refactoring.)
Solving the challenges and what not is a feat in itself, learning the clever ways to refactor your code come with experience. There are a number of really great JavaScript books however if you want a deeper understanding of the language.
The three links @iamknox posted are really awesome learning material, especially the first one. I love Kyle Simpsons books and videos, he explain’s JavaScript in a very different way and is extremely thoroughly with it. I learned a lot from him.
If you didn’t start already, learning EcmaScript 2015 (ES6) will help you write cleaner code, as this is a newer version of the JavaScript standard with many new language features, such as a different function syntax. I find this a lot cleaner, here is a simple example:
// Old syntax
fs.readFile('file.txt', function(err, content) {
console.log(content);
});
// New syntax
fs.readFile('file.txt', (err, content) => console.log(content));
Keep in mind that sometimes shorter isn’t always better. There are fancy one-liner solutions out there that can be impressive, however are difficult to decipher. Your code should be readable and understandable to humans.